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 "ByteMemoryVMatrix.h"
00042
00043
namespace PLearn {
00044
using namespace std;
00045
00046
PLEARN_IMPLEMENT_OBJECT(ByteMemoryVMatrix,
"ONE_LINE_DESCR",
"ONE LINE HELP");
00047
00050 ByteMemoryVMatrix::ByteMemoryVMatrix()
00051 : data(0)
00052 {
00053 }
00054
00055 ByteMemoryVMatrix::ByteMemoryVMatrix(
unsigned char* the_data,
int the_length,
int the_width,
Vec the_scale)
00056 :
inherited(the_length, the_width), data(the_data), scale(the_scale), offset_(the_scale.length())
00057 {
00058
if (the_scale.
length() != width_)
00059
PLERROR(
"ByteMemoryVMatrix: inconsistent arguments (scale(%d),n_col(%d))",
00060 the_scale.
length(), width_);
00061 }
00062
00063 ByteMemoryVMatrix::
00064 ByteMemoryVMatrix(
unsigned char* the_data,
int the_length,
int the_width,
00065
Vec the_scale,
Vec the_offset)
00066 :
VMatrix(the_length, the_width), data(the_data),
00067 scale(the_scale), offset_(the_offset)
00068 {
00069
if (the_scale.
length() != width_ || the_offset.
length()!=width_)
00070
PLERROR(
"ByteMemoryVMatrix: inconsistent arguments (scale(%d),offset(%d),n_col(%d))",
00071 the_scale.
length(), the_offset.
length(), width_);
00072 }
00073
00074 ByteMemoryVMatrix::ByteMemoryVMatrix(
unsigned char* the_data,
int the_length,
int the_width,
00075
double the_scaling_factor,
double the_offset)
00076 :
VMatrix(the_length, the_width), data(the_data),
00077 scale(the_width, the_scaling_factor), offset_(the_width, the_offset)
00078 {
00079 }
00080
00081 real ByteMemoryVMatrix::get(
int i,
int j)
const
00082
{
00083
return (
data[i*
width()+j] +
offset_[j] ) *
scale[j];
00084 }
00085
00086 void ByteMemoryVMatrix::getSubRow(
int i,
int j,
Vec samplevec)
const
00087
{
00088
unsigned char* p = &
data[i*width_];
00089
real *v = samplevec.
data();
00090
real *s =
scale.
data();
00091
real *o =
offset_.
data();
00092
for (
int jj=0; jj<samplevec.
length(); jj++)
00093 v[jj] = s[j+jj] * (p[j+jj] + o[j+jj]);
00094 }
00095
00096 }