ShMatrix.hpp
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 "ShVariable.hpp"
00031
#include "ShAttrib.hpp"
00032
#include "ShRefCount.hpp"
00033
00034
namespace SH {
00035
00036
template<
int Rows,
int Cols, ShBindingType Binding,
typename T>
00037
class ShMatrix;
00038
00039
template<
int Rows,
int Cols,
typename T>
00040
class ShMatrixRows;
00041
00048
template<
int Rows,
int Cols, ShBindingType Binding,
typename T>
00049 class ShMatrix {
00050
public:
00051
00059
ShMatrix();
00060
00065
ShMatrix(
const ShMatrix<Rows, Cols, Binding, T>& other);
00066
00067
00072
template<ShBindingType Binding2>
00073
ShMatrix(
const ShMatrix<Rows, Cols, Binding2, T>& other);
00074
00075 ~
ShMatrix();
00076
00082
ShMatrix&
operator=(
const ShMatrix<Rows, Cols, Binding, T>& other);
00083
00089
template<ShBindingType Binding2>
00090
ShMatrix&
operator=(
const ShMatrix<Rows, Cols, Binding2, T>& other);
00091
00096
ShAttrib<Cols, Binding, T>&
operator[](
int i);
00097
00102
const ShAttrib<Cols, Binding, T>&
operator[](
int i)
const;
00103
00109
template<ShBindingType Binding2>
00110
ShMatrix&
operator+=(
const ShMatrix<Rows, Cols, Binding2, T>& other);
00111
00117
template<ShBindingType Binding2>
00118
ShMatrix&
operator-=(
const ShMatrix<Rows, Cols, Binding2, T>& other);
00119
00120
00127
template<ShBindingType Binding2>
00128
ShMatrix&
operator/=(
const ShMatrix<Rows, Cols, Binding2, T>& other);
00129
00130
00135
ShMatrix<Rows - 1, Cols -1, SH_TEMP, T>
subMatrix(
int,
int)
const;
00136
00137
void setTranslation(
const ShGeneric<Rows-1, T>& trans);
00138
00139
void setScaling(
const ShGeneric<Rows-1, T>&
scale);
00140
00141
00147
ShMatrix& operator*=(
const ShGeneric<1, T>& a);
00148
00153
ShMatrix&
operator/=(
const ShGeneric<1, T>& a);
00154
00160
ShMatrixRows<Rows, Cols, T> operator()()
const;
00161
ShMatrixRows<1, Cols, T> operator()(
int)
const;
00162
ShMatrixRows<2, Cols, T> operator()(
int,
int)
const;
00163
ShMatrixRows<3, Cols, T> operator()(
int,
int,
int)
const;
00164
ShMatrixRows<4, Cols, T> operator()(
int,
int,
int,
int)
const;
00166
00172
00175
void name(
const std::string& name);
00176 std::string
name()
const;
00177
00179
void range(T low, T high);
00180
00185
void internal(
bool setting);
00186
00188
00189
00190
private:
00195
ShAttrib<Cols, Binding, T> m_data[Rows];
00196
00197 };
00204
template<
int R,
int C, ShBindingType B,
typename Ty>
00205 std::ostream&
operator<<(std::ostream& out,
00206
const ShMatrix<R, C, B, Ty>& m);
00207
00214
template<
int Rows,
int Cols,
typename T>
00215 class ShMatrixRows {
00216
public:
00217
template<ShBindingType Binding>
00218
ShMatrixRows(
const ShMatrix<Rows, Cols, Binding, T>& source);
00219
00220
template<
int OR, ShBindingType Binding>
00221
ShMatrixRows(
const ShMatrix<OR, Cols, Binding, T>& source,
00222
int idx0);
00223
template<
int OR, ShBindingType Binding>
00224 ShMatrixRows(
const ShMatrix<OR, Cols, Binding, T>& source,
00225
int idx0,
int idx1);
00226
template<
int OR, ShBindingType Binding>
00227 ShMatrixRows(
const ShMatrix<OR, Cols, Binding, T>& source,
00228
int idx0,
int idx1,
int idx2);
00229
template<
int OR, ShBindingType Binding>
00230 ShMatrixRows(
const ShMatrix<OR, Cols, Binding, T>& source,
00231
int idx0,
int idx1,
int idx2,
int idx3);
00232
00233 ShMatrixRows(
const ShMatrixRows<Rows, Cols, T>& other);
00234
00235 ShMatrixRows& operator=(
const ShMatrixRows<Rows, Cols, T>& other);
00236
00241
ShMatrix<Rows, Cols, SH_TEMP, T> operator()()
const;
00242
ShMatrix<Rows, 1, SH_TEMP, T> operator()(
int)
const;
00243
ShMatrix<Rows, 2, SH_TEMP, T> operator()(
int,
int)
const;
00244
ShMatrix<Rows, 3, SH_TEMP, T> operator()(
int,
int,
int)
const;
00245
ShMatrix<Rows, 4, SH_TEMP, T> operator()(
int,
int,
int,
int)
const;
00247
private:
00248
ShAttrib<Cols, SH_TEMP, T> m_data[Rows];
00249 };
00250
00251
00252
typedef ShMatrix<1, 1, SH_INPUT, float> ShInputMatrix1x1f;
00253
typedef ShMatrix<1, 1, SH_OUTPUT, float> ShOutputMatrix1x1f;
00254
typedef ShMatrix<1, 1, SH_INOUT, float> ShInOutMatrix1x1f;
00255
typedef ShMatrix<1, 1, SH_TEMP, float> ShMatrix1x1f;
00256
typedef ShMatrix<1, 2, SH_INPUT, float> ShInputMatrix1x2f;
00257
typedef ShMatrix<1, 2, SH_OUTPUT, float> ShOutputMatrix1x2f;
00258
typedef ShMatrix<1, 2, SH_INOUT, float> ShInOutMatrix1x2f;
00259
typedef ShMatrix<1, 2, SH_TEMP, float> ShMatrix1x2f;
00260
typedef ShMatrix<1, 3, SH_INPUT, float> ShInputMatrix1x3f;
00261
typedef ShMatrix<1, 3, SH_OUTPUT, float> ShOutputMatrix1x3f;
00262
typedef ShMatrix<1, 3, SH_INOUT, float> ShInOutMatrix1x3f;
00263
typedef ShMatrix<1, 3, SH_TEMP, float> ShMatrix1x3f;
00264
typedef ShMatrix<1, 4, SH_INPUT, float> ShInputMatrix1x4f;
00265
typedef ShMatrix<1, 4, SH_OUTPUT, float> ShOutputMatrix1x4f;
00266
typedef ShMatrix<1, 4, SH_INOUT, float> ShInOutMatrix1x4f;
00267
typedef ShMatrix<1, 4, SH_TEMP, float> ShMatrix1x4f;
00268
00269
typedef ShMatrix<2, 1, SH_INPUT, float> ShInputMatrix2x1f;
00270
typedef ShMatrix<2, 1, SH_OUTPUT, float> ShOutputMatrix2x1f;
00271
typedef ShMatrix<2, 1, SH_INOUT, float> ShInOutMatrix2x1f;
00272
typedef ShMatrix<2, 1, SH_TEMP, float> ShMatrix2x1f;
00273
typedef ShMatrix<2, 2, SH_INPUT, float> ShInputMatrix2x2f;
00274
typedef ShMatrix<2, 2, SH_OUTPUT, float> ShOutputMatrix2x2f;
00275
typedef ShMatrix<2, 2, SH_INOUT, float> ShInOutMatrix2x2f;
00276
typedef ShMatrix<2, 2, SH_TEMP, float> ShMatrix2x2f;
00277
typedef ShMatrix<2, 3, SH_INPUT, float> ShInputMatrix2x3f;
00278
typedef ShMatrix<2, 3, SH_OUTPUT, float> ShOutputMatrix2x3f;
00279
typedef ShMatrix<2, 3, SH_INOUT, float> ShInOutMatrix2x3f;
00280
typedef ShMatrix<2, 3, SH_TEMP, float> ShMatrix2x3f;
00281
typedef ShMatrix<2, 4, SH_INPUT, float> ShInputMatrix2x4f;
00282
typedef ShMatrix<2, 4, SH_OUTPUT, float> ShOutputMatrix2x4f;
00283
typedef ShMatrix<2, 4, SH_INOUT, float> ShInOutMatrix2x4f;
00284
typedef ShMatrix<2, 4, SH_TEMP, float> ShMatrix2x4f;
00285
00286
typedef ShMatrix<3, 1, SH_INPUT, float> ShInputMatrix3x1f;
00287
typedef ShMatrix<3, 1, SH_OUTPUT, float> ShOutputMatrix3x1f;
00288
typedef ShMatrix<3, 1, SH_INOUT, float> ShInOutMatrix3x1f;
00289
typedef ShMatrix<3, 1, SH_TEMP, float> ShMatrix3x1f;
00290
typedef ShMatrix<3, 2, SH_INPUT, float> ShInputMatrix3x2f;
00291
typedef ShMatrix<3, 2, SH_OUTPUT, float> ShOutputMatrix3x2f;
00292
typedef ShMatrix<3, 2, SH_INOUT, float> ShInOutMatrix3x2f;
00293
typedef ShMatrix<3, 2, SH_TEMP, float> ShMatrix3x2f;
00294
typedef ShMatrix<3, 3, SH_INPUT, float> ShInputMatrix3x3f;
00295
typedef ShMatrix<3, 3, SH_OUTPUT, float> ShOutputMatrix3x3f;
00296
typedef ShMatrix<3, 3, SH_INOUT, float> ShInOutMatrix3x3f;
00297
typedef ShMatrix<3, 3, SH_TEMP, float> ShMatrix3x3f;
00298
typedef ShMatrix<3, 4, SH_INPUT, float> ShInputMatrix3x4f;
00299
typedef ShMatrix<3, 4, SH_OUTPUT, float> ShOutputMatrix3x4f;
00300
typedef ShMatrix<3, 4, SH_INOUT, float> ShInOutMatrix3x4f;
00301
typedef ShMatrix<3, 4, SH_TEMP, float> ShMatrix3x4f;
00302
00303
typedef ShMatrix<4, 1, SH_INPUT, float> ShInputMatrix4x1f;
00304
typedef ShMatrix<4, 1, SH_OUTPUT, float> ShOutputMatrix4x1f;
00305
typedef ShMatrix<4, 1, SH_INOUT, float> ShInOutMatrix4x1f;
00306
typedef ShMatrix<4, 1, SH_TEMP, float> ShMatrix4x1f;
00307
typedef ShMatrix<4, 2, SH_INPUT, float> ShInputMatrix4x2f;
00308
typedef ShMatrix<4, 2, SH_OUTPUT, float> ShOutputMatrix4x2f;
00309
typedef ShMatrix<4, 2, SH_INOUT, float> ShInOutMatrix4x2f;
00310
typedef ShMatrix<4, 2, SH_TEMP, float> ShMatrix4x2f;
00311
typedef ShMatrix<4, 3, SH_INPUT, float> ShInputMatrix4x3f;
00312
typedef ShMatrix<4, 3, SH_OUTPUT, float> ShOutputMatrix4x3f;
00313
typedef ShMatrix<4, 3, SH_INOUT, float> ShInOutMatrix4x3f;
00314
typedef ShMatrix<4, 3, SH_TEMP, float> ShMatrix4x3f;
00315
typedef ShMatrix<4, 4, SH_INPUT, float> ShInputMatrix4x4f;
00316
typedef ShMatrix<4, 4, SH_OUTPUT, float> ShOutputMatrix4x4f;
00317
typedef ShMatrix<4, 4, SH_INOUT, float> ShInOutMatrix4x4f;
00318
typedef ShMatrix<4, 4, SH_TEMP, float> ShMatrix4x4f;
00319
00320 }
00321
00322
#include "ShMatrixImpl.hpp"
00323
00324
#endif
00325
Generated on Mon Oct 18 14:17:39 2004 for Sh by
1.3.7