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
00033
00034
00035
00036
00037
00038
00039
00040
00044
#include "SourceVMatrix.h"
00045
00046
namespace PLearn {
00047
using namespace std;
00048
00049
00050 SourceVMatrix::SourceVMatrix()
00051 :
inherited()
00052
00053 {
00054
00055
00056
00057
00058 }
00059
00060
PLEARN_IMPLEMENT_OBJECT(
SourceVMatrix,
00061
"Super-class for VMatrices that point to another one (the source vmatrix)",
00062
""
00063 );
00064
00065 void SourceVMatrix::setMetaDataDir(
const string& the_metadatadir)
00066 {
00067 inherited::setMetaDataDir(the_metadatadir);
00068
if(!
source->hasMetaDataDir())
00069
source->setMetaDataDir(the_metadatadir+
slash+
"Source"+
slash);
00070
00071
00072
if(
hasFieldInfos())
00073 {
00074
for(
int j=0; j<width_; j++)
00075 {
00076
string fnam = fieldName(j);
00077
if(!
file_exists(getSFIFFilename(fnam,
".smap")) &&
file_exists(
source->getSFIFFilename(fnam,
".smap")))
00078 setSFIFFilename(fnam,
".smap",
source->getSFIFFilename(fnam,
".smap"));
00079
if(!
file_exists(getSFIFFilename(fnam,
".notes")) &&
file_exists(
source->getSFIFFilename(fnam,
".notes")))
00080 setSFIFFilename(fnam,
".notes",
source->getSFIFFilename(fnam,
".notes"));
00081
if(!
file_exists(getSFIFFilename(fnam,
".binning")) &&
file_exists(
source->getSFIFFilename(fnam,
".binning")))
00082 setSFIFFilename(fnam,
".binning",
source->getSFIFFilename(fnam,
".binning"));
00083 }
00084 }
00085 }
00086
00087 void SourceVMatrix::declareOptions(
OptionList& ol)
00088 {
00089
declareOption(ol,
"source", &SourceVMatrix::source, OptionBase::buildoption,
00090
"The source VMatrix");
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 inherited::declareOptions(ol);
00103 }
00104
00105 void SourceVMatrix::build_()
00106 {
00107
00108
00109
00110
00111
00112
00113 }
00114
00115 void SourceVMatrix::setMetaInfoFromSource()
00116 {
00117 setMtime(
max(
getMtime(),
source->getMtime()));
00118
00119
00120
if(length_<0)
00121 length_ =
source->
length();
00122
if(width_<0)
00123 width_ =
source->
width();
00124
00125
00126
if(inputsize_<0)
00127 inputsize_ =
source->inputsize();
00128
if(targetsize_<0)
00129 targetsize_ =
source->targetsize();
00130
if(weightsize_<0)
00131 weightsize_ =
source->weightsize();
00132
00133
00134
if(!
hasFieldInfos() && (
width() ==
source->
width()) &&
source->hasFieldInfos() )
00135 setFieldInfos(
source->getFieldInfos());
00136
00137
00138
if (map_rs.
length() == 0) {
00139 map_rs.
resize(width_);
00140
for (
int j = 0; j < width_; j++) {
00141
if (j <
source->
width()) {
00142 map_rs[j] =
source->getRealToStringMapping(j);
00143 }
else {
00144
00145 map_rs[j] = map<real,string>();
00146 }
00147 }
00148 }
00149
if (map_sr.
length() == 0) {
00150 map_sr.
resize(width_);
00151
for (
int j = 0; j < width_; j++) {
00152
if (j <
source->
width()) {
00153 map_sr[j] =
source->getStringToRealMapping(j);
00154 }
else {
00155
00156 map_sr[j] = map<string,real>();
00157 }
00158 }
00159 }
00160 }
00161
00162
00163 void SourceVMatrix::build()
00164 {
00165 inherited::build();
00166
build_();
00167 }
00168
00169 void SourceVMatrix::makeDeepCopyFromShallowCopy(map<const void*, void*>& copies)
00170 {
00171 inherited::makeDeepCopyFromShallowCopy(copies);
00172
deepCopyField(
sourcerow, copies);
00173
deepCopyField(
source, copies);
00174 }
00175
00177
00179 void SourceVMatrix::getNewRow(
int i,
const Vec& v)
const {
00180
PLERROR(
"In SourceVMatrix::getNewRow - getNewRow not implemented for this subclass of SourceVMatrix");
00181 }
00182
00183 }
00184