use from Ernesto Palacios

Dependents:   RoboticArm DXL_SDK_Porting_Test

Fork of Matrix by Ernesto Palacios

Revision:
6:3f01dc2d77f1
Parent:
5:a4014ab0a8cf
Child:
8:1774aa06ab99
diff -r a4014ab0a8cf -r 3f01dc2d77f1 Matrix.cpp
--- a/Matrix.cpp	Sun Oct 30 16:29:23 2011 +0000
+++ b/Matrix.cpp	Thu Feb 02 04:28:35 2017 +0000
@@ -159,7 +159,7 @@
                 Mat._matrix[i].resize( Mat._nCols );
 
             for( int i = 0; i < Mat._nRows; i++ )
-                for( int j = Mat._nCols; j > index; j-- )
+                for( int j = Mat._nCols-1; j > index; j-- )//stanley Mat._nCols =>Mat._nCols-1
                     Mat._matrix[i][j] = Mat._matrix[i][j - 1];
 
             for( int i = 0; i < Mat._nRows; i++ )
@@ -191,7 +191,7 @@
     }else{
 
         for( int i = 0; i < Mat._nRows; i++ )
-            for( int j = Col; j < Mat._nCols; j++ )
+            for( int j = Col; j < Mat._nCols-1; j++ ) //stanley  Mat._nCols=>Mat._nCols-1
                 Mat._matrix[i][j] = Mat._matrix[i][j+1];
 
         // If adressing last element of Column,
@@ -204,7 +204,7 @@
 
         //Erase last Column
         for( int i = 0; i < Mat._nRows; i++ )
-            Mat._matrix[i].reserve(Mat._nCols);
+            Mat._matrix[i].reserve(Mat._nCols); //待理解
 
     }
 }
@@ -241,6 +241,8 @@
     {
         printf( "\n\nERROR:\nRow out of dimmensions @ GetRow\n"
                 "Nothing Done.\n\n" );
+        Matrix NULL_M( 1, 1 );//暫時這樣stanley
+        return NULL_M;
 
     }else{
 
@@ -267,6 +269,9 @@
     {
         printf( "\n\nERROR:\nColumn out of dimmensions.\n"
                 "Nothing Done.\n\n" );
+        Matrix NULL_M( 1, 1 );//暫時這樣stanley
+        return NULL_M;
+
     }else{
 
         Matrix SingleCol( Mat._nRows, 1 );
@@ -362,6 +367,46 @@
     }
 }
 
+//stanley
+void Matrix::Vec_ext_1_row(Matrix& Vec,float number)
+{
+    
+    //Vec._nRows++;
+
+    if( Vec._nCols > 1 )
+    {
+        printf("\n\nERROR:\nOut of limits of Matrix @ mat.Vec_ext_1_row()");
+
+    }
+    else
+    {
+        for( int i = 0; i < _nRows-1; i++ )//複製前三列
+            _matrix[i][0] = Vec._matrix[i][0];
+
+        _matrix[_nRows-1][0] = number;//最後一列補0
+    }
+}
+
+//stanley
+//[Vec1 vec2 vec3 number]'  =>Just get [Vec1 vec2 vec3]
+void Matrix::Vec_export_3_row(Matrix& Vec)
+{
+    _nRows=3;
+    
+    if( Vec._nCols > 1 )
+    {
+        printf("\n\nERROR:\nOut of limits of Matrix @ mat.Vec_export_3_row()");
+
+    }
+    else
+    {
+        for( int i = 0; i < _nRows; i++ )//複製前三列
+            _matrix[i][0] = Vec._matrix[i][0];
+        
+    }
+
+}
+
 
 /// Adds all elements in matrix and returns the answer.
 float Matrix::sum() const