00001 #ifndef Impala_Core_Matrix_SetRow_h
00002 #define Impala_Core_Matrix_SetRow_h
00003
00004 #include "Basis/ILog.h"
00005 #include "Core/Matrix/MatFunc.h"
00006 #include "Core/Vector/VectorTem.h"
00007
00008 namespace Impala
00009 {
00010 namespace Core
00011 {
00012 namespace Matrix
00013 {
00014
00015 template<class MatT>
00016 inline void
00017 SetRow(MatT* m, int index, const Vector::VectorTem<Real64>& row)
00018 {
00019 ILOG_VAR(Impala.Core.Matrix.SetRow);
00020 int length = MatNrCol(m);
00021 if (length != row.Size())
00022 ILOG_ERROR_NODE("nonconformant operands");
00023 if (index < 0 || index >= MatNrRow(m))
00024 ILOG_ERROR_NODE("faulty row index: " << index);
00025 typename MatT::StorType* rowPtr = MatE(m, index);
00026 for (int i=0 ; i<length ; i++)
00027 rowPtr[i] = row[i];
00028 }
00029
00030 template<class MatT>
00031 inline void
00032 SetRow(MatT* dst, int dstIndex, MatT* src, int srcIndex)
00033 {
00034 ILOG_VAR(Impala.Core.Matrix.SetRow);
00035 int length = MatNrCol(dst);
00036 if (length != MatNrCol(src))
00037 ILOG_ERROR_NODE("nonconformant operands");
00038 if (dstIndex < 0 || dstIndex >= MatNrRow(dst))
00039 ILOG_ERROR_NODE("faulty row dstIndex: " << dstIndex);
00040 if (srcIndex < 0 || srcIndex >= MatNrRow(src))
00041 ILOG_ERROR_NODE("faulty row srcIndex: " << srcIndex);
00042 typename MatT::StorType* dstRowPtr = MatE(dst, dstIndex);
00043 typename MatT::StorType* srcRowPtr = MatE(src, srcIndex);
00044 for (int i=0 ; i<length ; i++)
00045 dstRowPtr[i] = srcRowPtr[i];
00046 }
00047
00048 }
00049 }
00050 }
00051
00052 #endif