Add scalar-matrix multiplication

This commit is contained in:
Pavel Krajcevski 2014-03-21 01:17:19 -04:00
parent 63b8744917
commit 2b17cf6f97

View file

@ -234,6 +234,54 @@ namespace FasTC {
ResultType GetMultiplication() const { return MultiplyMatrix(m_A, m_B); } ResultType GetMultiplication() const { return MultiplyMatrix(m_A, m_B); }
}; };
template<typename TypeOne, typename TypeTwo>
class MultSwitch<
eVectorType_Matrix,
eVectorType_Scalar,
TypeOne, TypeTwo> {
private:
const TypeOne &m_A;
const TypeTwo &m_B;
public:
typedef MatrixBase<typename TypeOne::ScalarType, TypeOne::kNumRows, TypeOne::kNumCols> ResultType;
MultSwitch(const TypeOne &a, const TypeTwo &b)
: m_A(a), m_B(b) { }
ResultType GetMultiplication() const {
TypeOne result;
for(int i = 0; i < TypeOne::Size; i++) {
result[i] = m_A[i] * m_B;
}
return result;
}
};
template<typename TypeOne, typename TypeTwo>
class MultSwitch<
eVectorType_Scalar,
eVectorType_Matrix,
TypeOne, TypeTwo> {
private:
const TypeOne &m_A;
const TypeTwo &m_B;
public:
typedef MatrixBase<typename TypeTwo::ScalarType, TypeTwo::kNumRows, TypeTwo::kNumCols> ResultType;
MultSwitch(const TypeOne &a, const TypeTwo &b)
: m_A(a), m_B(b) { }
ResultType GetMultiplication() const {
TypeTwo result;
for(int i = 0; i < TypeTwo::Size; i++) {
result[i] = m_A * m_B[i];
}
return result;
}
};
// Outer product... // Outer product...
template<typename _T, typename _U, const int N, const int M> template<typename _T, typename _U, const int N, const int M>
MatrixBase<_T, N, M> operator^( MatrixBase<_T, N, M> operator^(
@ -256,7 +304,6 @@ namespace FasTC {
) { ) {
return a ^ b; return a ^ b;
} }
}; };
#endif // BASE_INCLUDE_MATRIXBASE_H_ #endif // BASE_INCLUDE_MATRIXBASE_H_