A lite library for operations in linear algebra
Embed:
(wiki syntax)
Show/hide line numbers
MATRIX_PRIMITIVE.h
00001 #ifndef MATRIX_PRIMITIVE_H 00002 #define MATRIX_PRIMITIVE_H 00003 // 00004 #include <vector> 00005 #include <math.h> 00006 00007 using std::vector; 00008 00009 // Namespace MATRIX_PRIMITIVE 00010 ////////////////////////// 00011 namespace MATRIX_PRIMITIVE 00012 { 00013 00014 // Utilities 00015 /////////////////////////// 00016 void Mat_multiply_Vec(vector<float> &v_out, vector<vector<float> > &m_left, vector<float> &v_right); // v_out = m_left*v_right 00017 vector<float> Mat_multiply_Vec(vector<vector<float> > &m_left, vector<float> &v_right); // v_out = m_left*v_right 00018 00019 // New function for matrix multiply matrix 00020 vector<vector<float> > Mat_multiply_Mat(vector<vector<float> > &m_left, vector<vector<float> > &m_right); // m_out = m_left*m_right 00021 vector<float> Get_VectorPlus(const vector<float> &v_a, const vector<float> &v_b, bool is_minus); // v_a + (or -) v_b 00022 vector<float> Get_VectorScalarMultiply(const vector<float> &v_a, float scale); // scale*v_a 00023 00024 // Important! 00025 // New function for scale-up a vector 00026 // v_a *= scale 00027 void Get_VectorScaleUp(vector<float> &v_a, float scale); // v_a *= scale 00028 00029 // Increment 00030 void Get_VectorIncrement(vector<float> &v_a, const vector<float> &v_b, bool is_minus); // v_a += (or -=) v_b 00031 /////////////////////////// end Utilities 00032 00033 00034 // Matrix inversion, using Gauss method 00035 ///////////////////////////////////////// 00036 bool SolveSingularityOnDiag(vector<vector<float> > &M, vector<vector<float> > &M_inv, size_t i); 00037 00038 vector<vector<float> > MatrixInversion(vector<vector<float> > M); // Note: we need a copy of M, don't use reference 00039 ///////////////////////////////////////// end Matrix inversion, using Gauss method 00040 00041 } 00042 ////////////////////////// end Namespace MATRIX_PRIMITIVE 00043 00044 00045 #endif
Generated on Fri Jul 15 2022 15:12:08 by
1.7.2