Visualization Tool Kit(VTK)など

expression templateという技法でデザインされているため内部は非常に難解な物となっている.

matrix<double> //unbounded_array -> std::allocator 可変長
bounded_matrix<double, 4, 4> //bounded_array -> double [16] 固定長
c_matrix<double, 4, 4> // double[4][4] 固定長

使いにくければ,typedefすればいい.

typedef bounded_matrix<double, 4, 4> Matrix4x4;
typedef bounded_matrix<double, 3, 3> Matrix3x3;
typedef bounded_vector<double, 3> Vector3D;
typedef matrix_range< Matrix4x4 > SubMatrix;
typedef matrix_vector_slice< Matrix4x4 > ColumnVector; //普通にcolでとると同次変換の四行目が含まれてしまう

スカラーと行列・ベクトルについては演算子をオーバーロードしている一方,行列やベクトルの積については演算子を意図的にオーバーロードしていない.
We decided to use no operator overloading for the following other primitives: -Left multiplication of vectors with a matrix -Right multiplication of vectors with a matrix -Multiplication of matrices -Inner product of vectors -Outer product of vectors -Transpose of a matrix

開発者の意図を無視してオーバーロードさせるならば
  Matrix4x4 operator*( const Matrix4x4& lhs, const Matrix& rhs)
  {
    return boost::numeric::ublas::prod( lhs, rhs );
  }
とすればよいが,この場合コピーが発生するのでexpression templateが効かなくなる.
しかしexpression templateで掛け算をためるのは非常にまずいこと*1になるので構わない.

なお,逆行列やベクトルのクロス積の関数は用意されていない.LU分解はある.

コメントをかく


「http://」を含む投稿は禁止されています。

利用規約をご確認のうえご記入下さい

Menu

メニュー

チュートリアル

アルゴリズム(数学)

並列計算

STL

#include<memory> #include<string> #include<sstream> #include<algorithm> #include<functional> #include<numeric>

Media Foundation

【メニュー編集】
Wiki記法ガイド

メンバーのみ編集できます