#include <kernel-matrix.h>
Public Member Functions | |
KernelMatrix () | |
Creates an empty (0x0) matrix. | |
KernelMatrix (int size) | |
Creates a (size x size) identity matrix. | |
int | GetSize () const |
Gets the current size of the matrix. | |
void | Normalize () |
Normalizes by dividing k[r][c] by sqrt(k[r][r] * k[c][c]). | |
void | NormalizeByMinCardinality (const vector< int > &cards) |
Normalize by min cardinality. | |
void | Resize (int new_size) |
Resizes the matrix. | |
double & | at (int row, int col) |
Get a ref to the kernel value at row, col. | |
double | at (int row, int col) const |
Get the kernel value at row, col. | |
void | WriteToStream (ostream &output_stream) const |
Write the matrix to a stream. | |
void | WriteToFile (const char *filename) const |
Write the matrix to a stream. | |
void | ReadFromStream (istream &input_stream) |
Replaces all data in this matrix with new data from the stream. | |
void | ReadFromFile (const char *filename) |
Replaces all data in this matrix with new data from the file. |
KernelMatrix | ( | ) | [inline] |
Creates an empty (0x0) matrix.
KernelMatrix | ( | int | size | ) |
Creates a (size x size) identity matrix.
int GetSize | ( | ) | const |
Gets the current size of the matrix.
void Normalize | ( | ) |
Normalizes by dividing k[r][c] by sqrt(k[r][r] * k[c][c]).
void NormalizeByMinCardinality | ( | const vector< int > & | cards | ) |
Normalize by min cardinality.
Requires cards.size() == GetSize(). cards[i] is the cardinality of the ith set. This function will divide k[r][c] by the minimum of cards[r] and cards[c].
void Resize | ( | int | new_size | ) |
Resizes the matrix.
Warning: this can cause data loss if you are shrinking the matrix. If rows are added, any new elements on the diagonal are initialized to 1, all other new elements are 0.
double & at | ( | int | row, | |
int | col | |||
) |
Get a ref to the kernel value at row, col.
This allows you to do things like kernel.at(1, 3) = 37; KernelMatrix will automatically maintain symmetry, so that after you do this, if you call kernel.at(3, 1), it will be 37.
double at | ( | int | row, | |
int | col | |||
) | const |
Get the kernel value at row, col.
void WriteToStream | ( | ostream & | output_stream | ) | const |
Write the matrix to a stream.
File format:
void WriteToFile | ( | const char * | filename | ) | const |
void ReadFromStream | ( | istream & | input_stream | ) |
Replaces all data in this matrix with new data from the stream.
Aborts if the stream is bad. See WriteToStream() for the file format.
void ReadFromFile | ( | const char * | filename | ) |