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
00041
#include "ExtendedVMatrix.h"
00042
00043
namespace PLearn {
00044
using namespace std;
00045
00046
00049
PLEARN_IMPLEMENT_OBJECT(ExtendedVMatrix,
"ONE_LINE_DESC",
"ONE_LINE_HELP");
00050
00051 ExtendedVMatrix::ExtendedVMatrix()
00052 : top_extent(0), bottom_extent(0), left_extent(0), right_extent(0), fill_value(0)
00053 {
00054 }
00055
00056 ExtendedVMatrix::ExtendedVMatrix(
VMat the_distr,
int the_top_extent,
int the_bottom_extent,
00057
int the_left_extent,
int the_right_extent,
00058
real the_fill_value)
00059 :
inherited(the_distr->length()+the_top_extent+the_bottom_extent,
00060 the_distr->width()+the_left_extent+the_right_extent),
00061 distr(the_distr), top_extent(the_top_extent), bottom_extent(the_bottom_extent),
00062 left_extent(the_left_extent), right_extent(the_right_extent), fill_value(the_fill_value)
00063 {
00064 }
00065
00066
void
00067 ExtendedVMatrix::declareOptions(
OptionList &ol)
00068 {
00069
declareOption(ol,
"distr", &ExtendedVMatrix::distr, OptionBase::buildoption,
"");
00070
declareOption(ol,
"top_extent", &ExtendedVMatrix::top_extent, OptionBase::buildoption,
"");
00071
declareOption(ol,
"bottom_extent", &ExtendedVMatrix::bottom_extent, OptionBase::buildoption,
"");
00072
declareOption(ol,
"left_extent", &ExtendedVMatrix::left_extent, OptionBase::buildoption,
"");
00073
declareOption(ol,
"right_extent", &ExtendedVMatrix::right_extent, OptionBase::buildoption,
"");
00074
declareOption(ol,
"fill_value", &ExtendedVMatrix::fill_value, OptionBase::buildoption,
"");
00075 inherited::declareOptions(ol);
00076 }
00077
00078
void
00079 ExtendedVMatrix::build()
00080 {
00081 inherited::build();
00082
build_();
00083 }
00084
00085
void
00086 ExtendedVMatrix::build_()
00087 {
00088 }
00089
00090 void ExtendedVMatrix::getNewRow(
int i,
const Vec& v)
const
00091
{
00092
#ifdef BOUNDCHECK
00093
if(i<0 || i>=
length())
00094
PLERROR(
"In ExtendedVMatrix::getNewRow OUT OF BOUNDS");
00095
if(v.
length() !=
width())
00096
PLERROR(
"In ExtendedVMatrix::getNewRow v.length() must be equal to the VMat's width");
00097
#endif
00098
00099
if(i<top_extent || i>=
length()-
bottom_extent)
00100 v.
fill(
fill_value);
00101
else
00102 {
00103
Vec subv = v.
subVec(
left_extent,
distr->
width());
00104
distr->getRow(i-
top_extent,subv);
00105
if(
left_extent>0)
00106 v.
subVec(0,
left_extent).fill(
fill_value);
00107
if(
right_extent>0)
00108 v.
subVec(
width()-
right_extent,
right_extent).fill(
fill_value);
00109 }
00110 }
00111
00112 }