00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef MC_MATRIX_N_H_
00020 # define MC_MATRIX_N_H_
00021
00022
00023 #include <MC_double_vector.hpp>
00024
00025 #include <iostream>
00026
00027
00028 namespace mesh_conv
00029 {
00030
00031 class MC_int_vector;
00032 class MC_v3d;
00033 class MC_v4d;
00034 class MC_v3d_vector;
00035
00037
00040 class MC_matrix
00041 {
00042 public:
00043
00044
00045
00046
00047
00048
00049
00050
00052 MC_matrix();
00054 MC_matrix(const int& size_col,const int& size_row);
00056 MC_matrix(const int& size_col);
00058 MC_matrix(const MC_matrix& size_row);
00060 MC_matrix(const MC_v3d& v);
00062 MC_matrix(const MC_v3d& v1,const MC_v3d& v2);
00064 MC_matrix(const MC_v3d& v1,const MC_v3d& v2,const MC_v3d& v3);
00066 MC_matrix(const MC_v3d_vector& v);
00067
00068
00070 ~MC_matrix();
00071
00072
00073
00074
00075
00076
00077
00078
00079
00082 void check_integrity() const;
00083
00085 MC_matrix& clear();
00086
00088 int size_1() const;
00090 int size_2() const;
00092 MC_int_vector size() const;
00094 int size_vec() const;
00095
00096
00098 MC_matrix& resize(const MC_int_vector& new_size) ;
00100 MC_matrix& resize(const int& size_1,const int& size_2=-1) ;
00102 MC_matrix& resize_1(const int& size_1) ;
00104 MC_matrix& resize_2(const int& size_2) ;
00105
00106
00108 MC_matrix reshaped_1(const int& size_1) const;
00110 MC_matrix reshaped_2(const int& size_2) const;
00112 MC_matrix reshaped(const MC_int_vector& new_size) const;
00114 MC_matrix reshaped(const int& new_size_1,const int& new_size_2) const;
00115
00119 MC_matrix repmat(const int& k_repeat) const ;
00121 MC_matrix repmat(const int& k_repeat_1,const int& k_repeat_2) const ;
00123 MC_matrix repmat(const MC_int_vector& k_repeat) const ;
00125 MC_matrix repmat_1(const int& k_repeat_1) const ;
00127 MC_matrix repmat_2(const int& k_repeat_2) const ;
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00141 MC_matrix& set_block(const MC_int_vector& index_1,const MC_int_vector& index_2,const MC_matrix& block);
00145 MC_matrix& set_block(const int& start_x,const int& end_x,const int& start_y,const int& end_y,const MC_matrix& block);
00146
00148 const double& to_double() const;
00150 const MC_double_vector& to_vec () const;
00151
00153 MC_matrix& add_row(const MC_v3d& x0) ;
00155 MC_matrix& add_row(const MC_v3d& x0,const MC_v3d& x1) ;
00157 MC_matrix& add_row(const MC_v3d& x0,const MC_v3d& x1,const MC_v3d& x2);
00159 MC_matrix& add_row(const MC_double_vector& col);
00163 MC_matrix& set_row(const int& id_row,const MC_double_vector& row);
00164
00165
00167 MC_matrix& add_col(const MC_v3d& x0);
00169 MC_matrix& add_col(const MC_v3d& x0,const MC_v3d& x1);
00171 MC_matrix& add_col(const MC_v3d& x0,const MC_v3d& x1,const MC_v3d& x2);
00173 MC_matrix& add_col(const MC_double_vector& col);
00174
00179 MC_matrix& set_col(const int& id_col,const MC_double_vector& col);
00180
00181
00183 MC_matrix to_matrix4() const;
00186 std::pair <MC_matrix,MC_v3d> to_matrix3() const;
00187
00188
00189
00190
00191
00192
00193
00194
00196 static MC_matrix zeros(const int& size_1,const int& size_2);
00198 static MC_matrix zeros(const int& size);
00199
00201 static MC_matrix identity(const int& size);
00202
00208 static MC_matrix rotation_axis_to_axis(const MC_v3d& a1,const MC_v3d& a2);
00209
00216 static MC_matrix rotation_registration(const MC_matrix& X,const MC_matrix& X0);
00217
00222 static MC_matrix rotation(const MC_v3d& axis,const double& angle);
00228 static std::pair <MC_matrix,std::vector<MC_matrix> > rotation_axis_to_axis_with_gradient(const MC_v3d& a0,const MC_v3d& a1);
00229
00230
00231
00232
00233
00234
00235
00236
00237
00239 MC_matrix transposed() const;
00240
00243 MC_matrix inverted() const;
00244
00246 double det() const;
00247
00250 double norm_2() const;
00251
00253 double trace() const;
00254
00255
00256
00257
00258
00261 MC_matrix componentwise(const MC_matrix& M1) const;
00262
00263
00268 std::pair <MC_v3d,double> rotation_parameter() const;
00269
00270
00272 MC_matrix& operator+=(const double& a);
00274 MC_matrix& operator+=(const MC_matrix& M);
00276 MC_matrix& operator*=(const double& a);
00278 MC_matrix& operator/=(const double& a);
00279
00280
00281
00283 friend MC_matrix operator+(const MC_matrix& M1,const double& alpha);
00285 friend MC_matrix operator+(const double& alpha,const MC_matrix& M1);
00287 friend MC_matrix operator+(const MC_matrix& M1,const MC_matrix& M2);
00288
00289
00291 friend MC_matrix operator-(const MC_matrix& M1,const double& alpha);
00293 friend MC_matrix operator-(const double& alpha,const MC_matrix& M1);
00295 friend MC_matrix operator-(const MC_matrix& M1,const MC_matrix& M2);
00296
00298 friend MC_matrix operator*(const MC_matrix& M1,const double& alpha);
00300 friend MC_matrix operator*(const double& alpha,const MC_matrix& M1);
00302 friend MC_matrix operator*(const MC_matrix& M1,const MC_matrix& M2);
00304 friend MC_matrix operator*(const MC_matrix& M1,const MC_v3d& V);
00306 friend MC_double_vector operator*(const MC_matrix& M1,const MC_double_vector& v);
00307
00308
00309
00313 MC_matrix& operator*=(const MC_matrix& M1);
00314
00315
00316
00318 friend MC_matrix operator/(const MC_matrix& M1,const double& alpha);
00320 friend MC_matrix operator/(const double& alpha,const MC_matrix& M1);
00321
00327 void internal_product(MC_v3d* to_multiply) const;
00333 void internal_product(MC_v4d* to_multiply) const;
00334
00336 MC_matrix& add_translation(const MC_v3d& tr);
00337
00338
00339
00340
00341
00342
00343
00345 double& operator()(const int& k1,const int& k2);
00347 const double& operator()(const int& k1,const int& k2) const;
00351 double& operator()(const int& k_index);
00355 const double& operator()(const int& k_index) const;
00359 MC_matrix operator()(const MC_int_vector& k_index);
00360
00364 MC_matrix operator()(const MC_int_vector& index_1,const MC_int_vector& index_2) const;
00368 MC_matrix operator()(const std::string& string_index_1,const std::string& string_index_2);
00371 MC_matrix operator()(const std::string& string_index);
00372
00375 MC_v3d translation_part() const;
00376
00378 MC_matrix& set_translation(const MC_v3d& tr);
00379
00381 MC_matrix& set_rotation(const MC_matrix& m);
00382
00385 const double* pointer() const;
00386
00387
00388
00389
00390
00391
00392
00393
00395 friend std::ostream& operator << (std::ostream& stream,const MC_matrix& _M);
00396
00397
00398 private:
00399
00403 void analyse_string(const std::string& to_analyse,int dim,int *start,double *increment,int *end) const;
00405 void analyse_string(const char* to_analyse,int dim,int *start,double *increment,int *end) const;
00406
00407
00408
00409
00410
00412 MC_double_vector M;
00413
00416 int current_size[2];
00417
00418 };
00419
00420 }
00421
00422
00423 #endif