data_aux.h
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
00026
00027
00028
00029
00030
00031
00032 #ifndef DATA_AUX_H
00033 #define DATA_AUX_H
00034
00035 #include "fastlib/fastlib.h"
00036
00037 namespace data_aux {
00038
00053 template<typename T>
00054 static success_t Load(const char *fname, GenMatrix<T> *matrix) {
00055 Matrix tmp_matrix;
00056 success_t result = data::Load(fname, &tmp_matrix);
00057
00058
00059
00060 matrix->StaticInit(tmp_matrix.n_rows(), tmp_matrix.n_cols());
00061 for(index_t c = 0; c < tmp_matrix.n_cols(); c++) {
00062 for(index_t r = 0; r < tmp_matrix.n_rows(); r++) {
00063 matrix->set(r, c, STATIC_CAST(T, tmp_matrix.get(r, c)));
00064 }
00065 }
00066
00067 return result;
00068 }
00069
00084 template<typename T>
00085 static success_t LoadTranspose(const char *fname, GenMatrix<T> *matrix) {
00086 Matrix tmp_matrix;
00087 success_t result = data::Load(fname, &tmp_matrix);
00088
00089
00090
00091 matrix->StaticInit(tmp_matrix.n_cols(), tmp_matrix.n_rows());
00092 for(index_t c = 0; c < tmp_matrix.n_cols(); c++) {
00093 for(index_t r = 0; r < tmp_matrix.n_rows(); r++) {
00094 matrix->set(c, r, STATIC_CAST(T, tmp_matrix.get(r, c)));
00095 }
00096 }
00097
00098 return result;
00099 }
00100
00101 };
00102
00103 #endif