48 #ifndef KFILE_BINARY_HH 49 #define KFILE_BINARY_HH 93 kmatrix_file = orig.kmatrix_file;
98 template<
typename STDATA>
102 stData.getValue(
"kmatrix_file",kmatrix_file);
105 template<
typename STDATA>
109 stData.setValue(
"kmatrix_file", kmatrix_file);
114 return std::string(
"binary");
119 return std::string(
"binary format");
125 ParamInfo(
"kmatrix_file",
"kmf",
"string",
126 "filename of the float kernel-matrix"));
141 std::vector<unsigned int>& gIDs1,
142 std::vector<unsigned int>& gIDs2)
145 unsigned int ID2min = gIDs2[0];
146 unsigned int ID2max = gIDs2[gIDs2.size()-1];
147 unsigned int ID1min = gIDs1[0];
148 unsigned int ID1max = gIDs1[gIDs1.size()-1];
149 unsigned int rmin,rmax,cmin,cmax;
150 std::vector<unsigned int>::iterator git,git2;
152 float* row_data =
new float[ID2max-ID2min+1];
155 is =
new std::ifstream(kmatrix_file.c_str());
158 std::cerr <<
"error in opening kernel file \n";
165 std::string::size_type pr = kmatrix_file.find(
"rows",0);
166 std::string::size_type pc = kmatrix_file.find(
"cols",0);
167 std::string::size_type pe = kmatrix_file.find(
".kmf",0);
168 if (pr==std::string::npos || pc==std::string::npos ||
169 pe==std::string::npos)
171 std::cerr <<
"error in getting index-ranges from filename \n";
172 std::cerr <<
"required format of filename: \n";
173 std::cerr <<
"*-rows-RMIN-RMAX-cols-CMIN-CMAX.kmf\n";
177 std::string rrange = kmatrix_file.substr(pr+5,pc-pr-6);
178 std::string crange = kmatrix_file.substr(pc+5,pe-pc-5);
180 pr = rrange.find(
"-",0);
181 pc = crange.find(
"-",0);
183 rmin = atol(rrange.substr(0,pr).c_str());
184 rmax = atol(rrange.substr(pr+1).c_str());
185 cmin = atol(crange.substr(0,pc).c_str());
186 cmax = atol(crange.substr(pc+1).c_str());
194 if (ID1min<rmin || ID1max>rmax || ID2min<cmin || ID2max>cmax)
196 std::cerr <<
"index range in ID-lists exceed file-ID-range.\n";
201 unsigned int rind = 0;
202 for (git = gIDs1.begin();git!=gIDs1.end(); git++,rind++)
205 unsigned int pos_row_start = ((*git)-rmin)*4*(cmax-cmin+1);
207 is->seekg(pos_row_start + 4 * (ID2min-cmin) );
209 is->read( (
char*)row_data,(ID2max-ID2min+1)*4);
211 float* rStart = rowStarts[rind];
212 for (
unsigned int cind = 0; cind < gIDs2.size();cind++)
213 rStart[cind] = row_data[gIDs2[cind]-ID2min];
225 std::string kmatrix_file;
#define CHECK_MEMBER_TEMPLATE(c)
void loadParameters(STDATA &stData)
static std::string description()
void saveParameters(STDATA &stData) const
void operator=(const KFile_BINARY &orig)
static std::string name()
void setKmatrix_file(std::string kmf)
static void getParamInfos(std::vector< ParamInfo > &p)
KFile_BINARY(const KFile_BINARY &orig)
void load_matrix(float **rowStarts, std::vector< unsigned int > &gIDs1, std::vector< unsigned int > &gIDs2)
The ParamInfo class contains informations about one parameter like key, help text, guiHints etc.