TarzaNN
TarzaNN neural network simulator
|
#include <Matrix.h>
Public Member Functions | |
Matrix (const int nXSize, const int nYSize) | |
Matrix (const Matrix &matrix) | |
Matrix & | operator= (const Matrix &matrix) |
Matrix & | copyData (const Matrix &matrix) |
void * | getImage () |
void * | getImageCopy (uint32_t *x, uint32_t *y, uint32_t *size, void *p) |
bool | isZero () |
QPoint * | getNonZero () |
void | setValue (float value) |
void | setZero () |
void | setOne () |
void | multiplyScalar (float item) |
void | addScalar (float item) |
void | addMatrix (Matrix *input) |
bool | equals (Matrix *input) |
bool | equals (Matrix *input, int tol) |
void | subtractMatrix (Matrix *input) |
void | dotSquare () |
void | punch_out (int window) |
void | circularMask () |
void | clamp (float the_value) |
void | applyGatingControl (Matrix *theGatingControl) |
void | applyIOR (Matrix *theIORMap) |
void | applyThreshold (float the_value) |
void | applyThresholdBinarize (float the_value) |
void | applyThresholdAndMark (float value, Matrix *gc) |
void | setPixels (unsigned char *data) |
void | setPixels (int *data) |
void | downsample (Matrix *input) |
void | downsample_skip (Matrix *input) |
void | upsample (Matrix *input) |
void | upsample_skip (Matrix *input, float fill=0) |
void | resample (Matrix *input, bool skip=false, float fill=0) |
float | average () |
void | setZeroMean () |
void | setOneSum () |
void | normalize (float scale) |
void | printContent () |
void | printContentMap () |
void | save (QDataStream *outStream) |
void | read (QDataStream *inStream) |
void | saveActivations (char *filename) |
QImage * | toSTMQImage (int max=255) |
void | scaleValues (float minScaleValue, float maxScaleValue) |
void | dotProduct (Matrix *otherMatrix) |
void | rectangleCopy (uint32_t r_w, uint32_t r_h, uint32_t x1, uint32_t y1, Matrix *otherMatrix, uint32_t o_x1, uint32_t o_y1) |
void | shift (int dx, int dy, int fillOption=0) |
void | rectangleFill (uint32_t x, uint32_t y, uint32_t w, uint32_t h, float theValue) |
float | sumAll () |
float | sumAllPositive () |
float | getMaxValue () |
float | getMinValue () |
float | sumAllAbsolute () |
void | addNoise () |
QPoint * | getMaxCoords () |
QPoint * | getMaxCoordsSpiral () |
int | changeBrightnessOp (int value, int brightness) |
int | changeContrastOp (int value, int contrast) |
int | changeGammaOp (int value, int gamma) |
int | changeUsingTable (int value, const int table[]) |
QImage | changeImage (ChangeOp changeOp, const QImage &image, int value) |
QImage | changeBrightness (const QImage &image, int brightness) |
QImage | changeContrast (const QImage &image, int contrast) |
QImage | changeGamma (const QImage &image, int gamma) |
Protected Member Functions | |
void | serialize (char *buf) |
Matrix (char *buf) | |
Matrix (QString fileName, int fileType) | |
int | getSendSize () |
void | createKernel (float *kernel) |
Matrix () | |
Protected Attributes | |
bool | created |
Matrix - 2D array of floats. Designed for speed:
The matrix is a 1D array of floats + 1D array of pointers to the beginning of the rows
Matrix::Matrix | ( | char * | buf | ) | [protected] |
Constructor from serialized Matrix. Used with void Matrix::serialize(char* buf)
Matrix::Matrix | ( | QString | fileName, |
int | fileType | ||
) | [protected] |
Constructor from file. Used by FileFilter.
Matrix::Matrix | ( | ) | [protected] |
Matrix::Matrix | ( | const int | nXSize, |
const int | nYSize | ||
) |
Matrix::Matrix | ( | const Matrix & | matrix | ) |
void Matrix::addMatrix | ( | Matrix * | input | ) |
void Matrix::addNoise | ( | ) |
void Matrix::addScalar | ( | float | item | ) |
void Matrix::applyGatingControl | ( | Matrix * | theGatingControl | ) |
void Matrix::applyIOR | ( | Matrix * | theIORMap | ) |
void Matrix::applyThreshold | ( | float | the_value | ) |
Threshold the matrix - all entries below the given value are set to zero
void Matrix::applyThresholdAndMark | ( | float | value, |
Matrix * | gc | ||
) |
Threshold the matrix and mark winners and losers in gc.
void Matrix::applyThresholdBinarize | ( | float | the_value | ) |
Threshold the matrix - all entries below the given value are set to zero, above set to 1
float Matrix::average | ( | ) |
QImage Matrix::changeBrightness | ( | const QImage & | image, |
int | brightness | ||
) |
int Matrix::changeBrightnessOp | ( | int | value, |
int | brightness | ||
) | [inline] |
QImage Matrix::changeContrast | ( | const QImage & | image, |
int | contrast | ||
) |
int Matrix::changeContrastOp | ( | int | value, |
int | contrast | ||
) | [inline] |
QImage Matrix::changeGamma | ( | const QImage & | image, |
int | gamma | ||
) |
int Matrix::changeGammaOp | ( | int | value, |
int | gamma | ||
) | [inline] |
QImage Matrix::changeImage | ( | ChangeOp | changeOp, |
const QImage & | image, | ||
int | value | ||
) |
int Matrix::changeUsingTable | ( | int | value, |
const int | table[] | ||
) | [inline] |
void Matrix::circularMask | ( | ) |
void Matrix::clamp | ( | float | the_value | ) |
void Matrix::createKernel | ( | float * | kernel | ) | [protected] |
Creates a packed array representation of the Matrix. Used by Filter::getKernel.
void Matrix::dotProduct | ( | Matrix * | otherMatrix | ) |
A "flavoured" version of the product. Each element is multiplied with the corresponding one from the other matrix. The otherMatrix is not modified.
void Matrix::dotSquare | ( | ) |
Square element by element (used by NonFourier Neurons)
void Matrix::downsample | ( | Matrix * | input | ) |
Downsample with averaging
void Matrix::downsample_skip | ( | Matrix * | input | ) |
Downsample skipping pixels
bool Matrix::equals | ( | Matrix * | input | ) |
bool Matrix::equals | ( | Matrix * | input, |
int | tol | ||
) |
void * Matrix::getImage | ( | ) |
Get the data
void * Matrix::getImageCopy | ( | uint32_t * | x, |
uint32_t * | y, | ||
uint32_t * | size, | ||
void * | p | ||
) |
Get a copy of the data in the buffer provided, or allocate a buffer
x | The width of the image |
y | The height of the image |
size | The seize of the buffer |
p | The buffer (function will allocate if NULL) |
QPoint * Matrix::getMaxCoords | ( | ) |
Coordinates of maximum element (first)
QPoint * Matrix::getMaxCoordsSpiral | ( | ) |
Coordinates of maximum element starting in the center and seacrhing in a spiral (max closest to center)
float Matrix::getMaxValue | ( | ) | [inline] |
Max element in matrix
float Matrix::getMinValue | ( | ) |
Min element in matrix
QPoint * Matrix::getNonZero | ( | ) |
Find the coordinates of the first non-zero element in the matrix. Used for STM WTA. Will need to add another function that somehow localizes all the non-zero elements.
int Matrix::getSendSize | ( | ) | [protected] |
Size of buffer needed for network communications. For serialize().
Reimplemented in OutputImage.
bool Matrix::isZero | ( | ) |
void Matrix::multiplyScalar | ( | float | item | ) |
void Matrix::normalize | ( | float | scale | ) |
void Matrix::printContent | ( | ) |
void Matrix::printContentMap | ( | ) |
void Matrix::punch_out | ( | int | window | ) |
void Matrix::read | ( | QDataStream * | inStream | ) |
void Matrix::rectangleCopy | ( | uint32_t | r_w, |
uint32_t | r_h, | ||
uint32_t | x1, | ||
uint32_t | y1, | ||
Matrix * | otherMatrix, | ||
uint32_t | o_x1, | ||
uint32_t | o_y1 | ||
) |
copies the data from other matrix from a ractangle of size (r_w,r_h) locate at (o_x1,o_y1) into a similar rectangle in the current matrix at (x1,y1).
void Matrix::rectangleFill | ( | uint32_t | x, |
uint32_t | y, | ||
uint32_t | w, | ||
uint32_t | h, | ||
float | theValue | ||
) |
fills a rectangle with a specified value
void Matrix::resample | ( | Matrix * | input, |
bool | skip = false , |
||
float | fill = 0 |
||
) |
void Matrix::save | ( | QDataStream * | outStream | ) |
void Matrix::saveActivations | ( | char * | filename | ) |
void Matrix::scaleValues | ( | float | minScaleValue, |
float | maxScaleValue | ||
) |
Modifies the values so that they are within this new range.
void Matrix::serialize | ( | char * | buf | ) | [protected] |
Serialize the Matrix into the provided buffer. Called from OutputImage, used with Matrix::Matrix( char* buf)
Reimplemented in OutputImage.
void Matrix::setOne | ( | ) | [inline] |
void Matrix::setOneSum | ( | ) |
void Matrix::setPixels | ( | unsigned char * | data | ) |
void Matrix::setPixels | ( | int * | data | ) |
void Matrix::setValue | ( | float | value | ) | [inline] |
void Matrix::setZero | ( | ) | [inline] |
void Matrix::setZeroMean | ( | ) |
void Matrix::shift | ( | int | dx, |
int | dy, | ||
int | fillOption = 0 |
||
) |
Shifts the content of the matrix by the dx,dy. The rest is filled with 0z for now. if more fill controll needed, further develop the fillOption parameter
fillOption - currently ignored in the current implementation - the empty space gets padded with 0-zz
void Matrix::subtractMatrix | ( | Matrix * | input | ) |
float Matrix::sumAll | ( | ) | [inline] |
Sum of all matrix elements
float Matrix::sumAllAbsolute | ( | ) |
float Matrix::sumAllPositive | ( | ) | [inline] |
Sum of all positive matrix elements
QImage * Matrix::toSTMQImage | ( | int | max = 255 | ) |
Creates an QImage out of the matrix.
void Matrix::upsample | ( | Matrix * | input | ) |
Upsample duplicating pixels
void Matrix::upsample_skip | ( | Matrix * | input, |
float | fill = 0 |
||
) |
Upsample filling with zero
bool Matrix::created [protected] |