This class provides with operations for Matrix Objects

Dependents:   Matrix_class Wizardsneverdie mbed_multiplex_matrix Kinematics_Project_G5 ... more

Revision:
5:93948a9bbde2
Parent:
4:d360c068d55f
Child:
6:aa5e94cddb3f
--- a/MatrixMath.cpp	Sun Oct 30 04:48:15 2011 +0000
+++ b/MatrixMath.cpp	Sun Oct 30 19:21:30 2011 +0000
@@ -1,9 +1,11 @@
 /**
  * @brief  version 0.9
  * @file   MatrixMath.cpp
- * @author Erneseto Palacios
+ * @author Ernesto Palacios
  *
- *  Develop Under  GPL v3.0 License
+ * Created on 15 de septiembre de 2011, 09:44 AM.
+ *
+ * Develop Under  GPL v3.0 License
  * http://www.gnu.org/licenses/gpl-3.0.html
  */
 
@@ -43,8 +45,8 @@
 
             }else{
                 printf( "\n\nWANRING: same matrix returned");
-                printf( "\nSingular Matrix, cannot perform Invert @matrix " );
-//                Mat.print();
+                printf( "\nSingular Matrix, cannot perform Invert @matrix\n " );
+                Mat.print();
                 printf( "\n  _____________\n" );
 
                 return Mat;
@@ -83,8 +85,8 @@
 
             }else{
                 printf( "\n\nWANRING: same matrix returned");
-                printf( "\nSingular Matrix, cannot perform Invert @matrix " );
-          //      Mat.print();
+                printf( "\nSingular Matrix, cannot perform Invert @matrix\n" );
+                Mat.print();
                 printf( "\n  _____________\n" );
 
                 return Mat;
@@ -93,7 +95,7 @@
         }
 
     }else{
-        printf( "\n\nERROR:\nMust be square Matrix @ MatrixMath::Determinant " );
+        printf( "\n\nERROR:\nMust be square Matrix @ MatrixMath::Determinant\n" );
     }
 }
 
@@ -107,8 +109,11 @@
     return Identity;
 }
 
-
-
+// Very Versitle Function. Accepts two Vector Matrices of any type:
+// Vector types may be: [n,1] dot [n,1]  
+//                      [n,1] dot [1,n]  always same
+//                      [1,n] dot [n,1]    'depth'
+//                      [1,n] dot [1,n]
 float MatrixMath::dot(const Matrix& leftM, const Matrix& rightM)
 {
     if( leftM.isVector() && rightM.isVector() )
@@ -206,7 +211,7 @@
         else if( Mat._nRows == 3 ) // 3x3 Matrix
         {
             float det;
-            MatrixMath dummy;
+            MatrixMath dummy; //For Private Method.
 
             det = dummy.Det3x3( Mat );
             return det;
@@ -222,23 +227,23 @@
                 Matrix reduced( Mat );           // Copy Original Matrix
                 Matrix::DeleteRow( reduced, 1); // Delete First Row
 
-                if( i%2 == 0 ) //Odd Rows
+                if( i%2 == 0 ) //Even Rows
                 {
 
                     Matrix::DeleteCol( reduced, i+1);
                     part1 += Mat._matrix[0][i] * MatrixMath::det(reduced);
                 }
-                else  // Even Rows
+                else  // Odd Rows
                 {
                     Matrix::DeleteCol( reduced, i+1);
                     part2 += Mat._matrix[0][i] * MatrixMath::det(reduced);
                 }
             }
-            return part1 - part2; //
+            return part1 - part2; 
         }
 
     }else{
-        printf("\n\nERROR:\nMatrix must be square Matrix @ MatrixMath::Det");
+        printf("\n\nERROR:\nMatrix must be square Matrix @ MatrixMath::det");
     }
 }