00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00027 #ifndef SH_SHMATRIX_HPP
00028 #define SH_SHMATRIX_HPP
00029
00030 #include "ShMeta.hpp"
00031 #include "ShVariable.hpp"
00032 #include "ShAttrib.hpp"
00033 #include "ShRefCount.hpp"
00034
00035 namespace SH {
00036
00037 template<int Rows, int Cols, ShBindingType Binding, typename T>
00038 class ShMatrix;
00039
00040 template<int Rows, int Cols, typename T>
00041 class ShMatrixRows;
00042
00049 template<int Rows, int Cols, ShBindingType Binding, typename T>
00050 class ShMatrix: public virtual ShMeta {
00051 public:
00052 typedef typename ShHostType<T>::type H;
00053 typedef H HostType;
00054
00062 ShMatrix();
00063
00068 ShMatrix(const ShMatrix<Rows, Cols, Binding, T>& other);
00069
00070
00075 template<ShBindingType Binding2>
00076 ShMatrix(const ShMatrix<Rows, Cols, Binding2, T>& other);
00077
00078 ~ShMatrix();
00079
00085 ShMatrix& operator=(const ShMatrix<Rows, Cols, Binding, T>& other);
00086
00092 template<ShBindingType Binding2>
00093 ShMatrix& operator=(const ShMatrix<Rows, Cols, Binding2, T>& other);
00094
00099 ShAttrib<Cols, Binding, T>& operator[](int i);
00100
00105 const ShAttrib<Cols, Binding, T>& operator[](int i) const;
00106
00112 template<ShBindingType Binding2>
00113 ShMatrix& operator+=(const ShMatrix<Rows, Cols, Binding2, T>& other);
00114
00120 template<ShBindingType Binding2>
00121 ShMatrix& operator-=(const ShMatrix<Rows, Cols, Binding2, T>& other);
00122
00123
00130 template<ShBindingType Binding2>
00131 ShMatrix& operator/=(const ShMatrix<Rows, Cols, Binding2, T>& other);
00132
00133
00138 ShMatrix<Rows - 1, Cols -1, SH_TEMP, T> subMatrix(int,int) const;
00139
00140 void setTranslation(const ShGeneric<Rows-1, T>& trans);
00141
00142 void setScaling(const ShGeneric<Rows-1, T>& scale);
00143
00144
00150 ShMatrix& operator*=(const ShGeneric<1, T>& a);
00151
00156 ShMatrix& operator/=(const ShGeneric<1, T>& a);
00157
00163 ShMatrixRows<Rows, Cols, T> operator()() const;
00164 ShMatrixRows<1, Cols, T> operator()(int) const;
00165 ShMatrixRows<2, Cols, T> operator()(int, int) const;
00166 ShMatrixRows<3, Cols, T> operator()(int, int, int) const;
00167 ShMatrixRows<4, Cols, T> operator()(int, int, int, int) const;
00169
00175
00177 void range(H low, H high);
00178
00180
00181 virtual std::string name() const;
00182 virtual void name(const std::string& n);
00183 virtual bool has_name() const;
00184
00185 virtual bool internal() const;
00186 virtual void internal(bool);
00187
00188 virtual std::string title() const;
00189 virtual void title(const std::string& t);
00190
00191 virtual std::string description() const;
00192 virtual void description(const std::string& d);
00193
00194 virtual std::string meta(const std::string& key) const;
00195 virtual void meta(const std::string& key, const std::string& value);
00196
00197 private:
00202 ShAttrib<Cols, Binding, T> m_data[Rows];
00203
00204 };
00211 template<int R, int C, ShBindingType B, typename Ty>
00212 std::ostream& operator<<(std::ostream& out,
00213 const ShMatrix<R, C, B, Ty>& m);
00214
00221 template<int Rows, int Cols, typename T>
00222 class ShMatrixRows {
00223 public:
00224 template<ShBindingType Binding>
00225 ShMatrixRows(const ShMatrix<Rows, Cols, Binding, T>& source);
00226
00227 template<int OR, ShBindingType Binding>
00228 ShMatrixRows(const ShMatrix<OR, Cols, Binding, T>& source,
00229 int idx0);
00230 template<int OR, ShBindingType Binding>
00231 ShMatrixRows(const ShMatrix<OR, Cols, Binding, T>& source,
00232 int idx0, int idx1);
00233 template<int OR, ShBindingType Binding>
00234 ShMatrixRows(const ShMatrix<OR, Cols, Binding, T>& source,
00235 int idx0, int idx1, int idx2);
00236 template<int OR, ShBindingType Binding>
00237 ShMatrixRows(const ShMatrix<OR, Cols, Binding, T>& source,
00238 int idx0, int idx1, int idx2, int idx3);
00239
00240 ShMatrixRows(const ShMatrixRows<Rows, Cols, T>& other);
00241
00242 ShMatrixRows& operator=(const ShMatrixRows<Rows, Cols, T>& other);
00243
00248 ShMatrix<Rows, Cols, SH_TEMP, T> operator()() const;
00249 ShMatrix<Rows, 1, SH_TEMP, T> operator()(int) const;
00250 ShMatrix<Rows, 2, SH_TEMP, T> operator()(int, int) const;
00251 ShMatrix<Rows, 3, SH_TEMP, T> operator()(int, int, int) const;
00252 ShMatrix<Rows, 4, SH_TEMP, T> operator()(int, int, int, int) const;
00254 private:
00255 ShAttrib<Cols, SH_TEMP, T> m_data[Rows];
00256 };
00257
00258
00259 typedef ShMatrix<1, 1, SH_INPUT, float> ShInputMatrix1x1f;
00260 typedef ShMatrix<1, 1, SH_OUTPUT, float> ShOutputMatrix1x1f;
00261 typedef ShMatrix<1, 1, SH_INOUT, float> ShInOutMatrix1x1f;
00262 typedef ShMatrix<1, 1, SH_TEMP, float> ShMatrix1x1f;
00263 typedef ShMatrix<1, 2, SH_INPUT, float> ShInputMatrix1x2f;
00264 typedef ShMatrix<1, 2, SH_OUTPUT, float> ShOutputMatrix1x2f;
00265 typedef ShMatrix<1, 2, SH_INOUT, float> ShInOutMatrix1x2f;
00266 typedef ShMatrix<1, 2, SH_TEMP, float> ShMatrix1x2f;
00267 typedef ShMatrix<1, 3, SH_INPUT, float> ShInputMatrix1x3f;
00268 typedef ShMatrix<1, 3, SH_OUTPUT, float> ShOutputMatrix1x3f;
00269 typedef ShMatrix<1, 3, SH_INOUT, float> ShInOutMatrix1x3f;
00270 typedef ShMatrix<1, 3, SH_TEMP, float> ShMatrix1x3f;
00271 typedef ShMatrix<1, 4, SH_INPUT, float> ShInputMatrix1x4f;
00272 typedef ShMatrix<1, 4, SH_OUTPUT, float> ShOutputMatrix1x4f;
00273 typedef ShMatrix<1, 4, SH_INOUT, float> ShInOutMatrix1x4f;
00274 typedef ShMatrix<1, 4, SH_TEMP, float> ShMatrix1x4f;
00275
00276 typedef ShMatrix<2, 1, SH_INPUT, float> ShInputMatrix2x1f;
00277 typedef ShMatrix<2, 1, SH_OUTPUT, float> ShOutputMatrix2x1f;
00278 typedef ShMatrix<2, 1, SH_INOUT, float> ShInOutMatrix2x1f;
00279 typedef ShMatrix<2, 1, SH_TEMP, float> ShMatrix2x1f;
00280 typedef ShMatrix<2, 2, SH_INPUT, float> ShInputMatrix2x2f;
00281 typedef ShMatrix<2, 2, SH_OUTPUT, float> ShOutputMatrix2x2f;
00282 typedef ShMatrix<2, 2, SH_INOUT, float> ShInOutMatrix2x2f;
00283 typedef ShMatrix<2, 2, SH_TEMP, float> ShMatrix2x2f;
00284 typedef ShMatrix<2, 3, SH_INPUT, float> ShInputMatrix2x3f;
00285 typedef ShMatrix<2, 3, SH_OUTPUT, float> ShOutputMatrix2x3f;
00286 typedef ShMatrix<2, 3, SH_INOUT, float> ShInOutMatrix2x3f;
00287 typedef ShMatrix<2, 3, SH_TEMP, float> ShMatrix2x3f;
00288 typedef ShMatrix<2, 4, SH_INPUT, float> ShInputMatrix2x4f;
00289 typedef ShMatrix<2, 4, SH_OUTPUT, float> ShOutputMatrix2x4f;
00290 typedef ShMatrix<2, 4, SH_INOUT, float> ShInOutMatrix2x4f;
00291 typedef ShMatrix<2, 4, SH_TEMP, float> ShMatrix2x4f;
00292
00293 typedef ShMatrix<3, 1, SH_INPUT, float> ShInputMatrix3x1f;
00294 typedef ShMatrix<3, 1, SH_OUTPUT, float> ShOutputMatrix3x1f;
00295 typedef ShMatrix<3, 1, SH_INOUT, float> ShInOutMatrix3x1f;
00296 typedef ShMatrix<3, 1, SH_TEMP, float> ShMatrix3x1f;
00297 typedef ShMatrix<3, 2, SH_INPUT, float> ShInputMatrix3x2f;
00298 typedef ShMatrix<3, 2, SH_OUTPUT, float> ShOutputMatrix3x2f;
00299 typedef ShMatrix<3, 2, SH_INOUT, float> ShInOutMatrix3x2f;
00300 typedef ShMatrix<3, 2, SH_TEMP, float> ShMatrix3x2f;
00301 typedef ShMatrix<3, 3, SH_INPUT, float> ShInputMatrix3x3f;
00302 typedef ShMatrix<3, 3, SH_OUTPUT, float> ShOutputMatrix3x3f;
00303 typedef ShMatrix<3, 3, SH_INOUT, float> ShInOutMatrix3x3f;
00304 typedef ShMatrix<3, 3, SH_TEMP, float> ShMatrix3x3f;
00305 typedef ShMatrix<3, 4, SH_INPUT, float> ShInputMatrix3x4f;
00306 typedef ShMatrix<3, 4, SH_OUTPUT, float> ShOutputMatrix3x4f;
00307 typedef ShMatrix<3, 4, SH_INOUT, float> ShInOutMatrix3x4f;
00308 typedef ShMatrix<3, 4, SH_TEMP, float> ShMatrix3x4f;
00309
00310 typedef ShMatrix<4, 1, SH_INPUT, float> ShInputMatrix4x1f;
00311 typedef ShMatrix<4, 1, SH_OUTPUT, float> ShOutputMatrix4x1f;
00312 typedef ShMatrix<4, 1, SH_INOUT, float> ShInOutMatrix4x1f;
00313 typedef ShMatrix<4, 1, SH_TEMP, float> ShMatrix4x1f;
00314 typedef ShMatrix<4, 2, SH_INPUT, float> ShInputMatrix4x2f;
00315 typedef ShMatrix<4, 2, SH_OUTPUT, float> ShOutputMatrix4x2f;
00316 typedef ShMatrix<4, 2, SH_INOUT, float> ShInOutMatrix4x2f;
00317 typedef ShMatrix<4, 2, SH_TEMP, float> ShMatrix4x2f;
00318 typedef ShMatrix<4, 3, SH_INPUT, float> ShInputMatrix4x3f;
00319 typedef ShMatrix<4, 3, SH_OUTPUT, float> ShOutputMatrix4x3f;
00320 typedef ShMatrix<4, 3, SH_INOUT, float> ShInOutMatrix4x3f;
00321 typedef ShMatrix<4, 3, SH_TEMP, float> ShMatrix4x3f;
00322 typedef ShMatrix<4, 4, SH_INPUT, float> ShInputMatrix4x4f;
00323 typedef ShMatrix<4, 4, SH_OUTPUT, float> ShOutputMatrix4x4f;
00324 typedef ShMatrix<4, 4, SH_INOUT, float> ShInOutMatrix4x4f;
00325 typedef ShMatrix<4, 4, SH_TEMP, float> ShMatrix4x4f;
00326
00327 }
00328
00329 #include "ShMatrixImpl.hpp"
00330
00331 #endif
00332