 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
25 "Usage: bmatrix [options] matrix_in.dat matrix_out.dat",
26 "-----------------------------------------------------",
27 "Processes matrices.",
30 "-random 4,7 Create a random matrix of the given size (rows & columns).",
31 "-negate Change the sign of the matrix.",
32 "-invert Invert by LU decomposition.",
33 "-svd Invert by singular value decomposition.",
34 "-window 5 Window over which to do permutations for linear sorting.",
35 "-preference -10 Homogenous preference for clustering.",
38 "-verbose 7 Verbosity of output.",
39 "-ln_1_R Use the -ln(1-R) conversion of the input matrix.",
40 "-lambda 0.6 Damping factor for clustering (default 0.5).",
42 "Parameters for image output:",
43 "-datatype b Force writing of a new data type.",
44 "-scale 3 Scale the image (must be an integer).",
45 "-color Convert to a heat map.",
48 "-vector file.dat Input a vector to multiply with the matrix.",
51 "-outvector file.dat Output the vector.",
52 "-outimage file.img Output the matrix as an image.",
57 int main(
int argc,
char** argv)
78 for ( curropt = option; curropt; curropt = curropt->
next ) {
79 if ( curropt->
tag ==
"random" ) {
80 if ( ( i = curropt->
values(m, n) ) < 1 )
81 cerr <<
"-random: A matrix size must be specified!" << endl;
85 if ( curropt->
tag ==
"negate" )
87 if ( curropt->
tag ==
"invert" )
89 if ( curropt->
tag ==
"svd" )
91 if ( curropt->
tag ==
"window" ) {
93 cerr <<
"-window: A window size must be specified!" << endl;
95 if ( window < 2 ) window = 2;
97 if ( curropt->
tag ==
"preference" )
98 if ( ( pref = curropt->
value.
real() ) < -1e36 )
99 cerr <<
"-preference: A preference value must be specified!" << endl;
100 if ( curropt->
tag ==
"ln_1_R" )
102 if ( curropt->
tag ==
"lambda" )
103 if ( ( lambda = curropt->
value.
real() ) < 0.001 )
104 cerr <<
"-lambda: A damping factor must be specified!" << endl;
105 if ( curropt->
tag ==
"datatype" )
107 if ( curropt->
tag ==
"scale" )
109 cerr <<
"-scale: An integer must be specified!" << endl;
110 if ( curropt->
tag ==
"color" ) img_color = 1;
111 if ( curropt->
tag ==
"vector" )
113 if ( curropt->
tag ==
"outvector" )
115 if ( curropt->
tag ==
"outimage" )
129 filename = argv[optind++];
130 matrix =
Matrix(filename);
134 cout <<
"Matrix size:" <<
tab << matrix.
rows() <<
" x " << matrix.
columns() << endl;
137 cout <<
"Input matrix:" << endl << matrix << endl;
139 if ( vector_file.
length() )
140 vector =
Matrix(vector_file);
149 cout <<
"Determinant: " << det << endl;
150 cout <<
"Inverse matrix:" << endl << matrix << endl;
157 cout <<
"Inverse matrix:" << endl << matrix << endl;
171 if ( pref > -1e36 ) {
172 for ( i=0; i<matrix.
rows(); i++ )
178 vector = matrix * vector;
180 if (
verbose && vector.rows() ) {
181 cout <<
"Output vector:" << endl << vector << endl;
185 cout <<
"Output matrix:" << endl << matrix << endl;
188 if ( vecout_file.
length() )
189 vector.
write(vecout_file);
191 if ( optind < argc ) {
192 filename = argv[optind];
193 matrix.
write(filename);
198 if ( img_file.
length() ) {
A class for a command line input option.
Header file for matrix functions.
Utility functions for matrices.
Header file for clustering functions.
int bexit(int value)
Exit function for cleanup and debugging.
Boption * get_option_list(const char *use[], int argc, char *argv[], int &optind)
Parses command line arguments based on a template.
Header file for option handlers.
Bimage * color_spectrum(double cmin, double cmax)
Colorizes an image to a spectrum.
long * affin_prop_clustering(Matrix s, long maxit, long convit, double lambda, long &ncluster)
Generate clusters from a similarity matrix using affinity propagation.
long values(T1 &v1, T2 &v2)
double singular_value_decomposition()
Singular value decomposition of a matrix .
int write_img(const char *filename, Bimage *p, int compression)
General driver function to write multiple image formats.
int matrix_log_1_R(Matrix matrix)
Calculates the logarithmic derivative of an R-factor in a matrix.
General image parameter class.
Utilities for timing functions.
double LU_decomposition()
Matrix inversion by LU decomposition.
Header file for image class.
int main(int argc, char **argv)
double timer_start()
Starts timer and prints the time.
Header file for general utilities.
ostream & tab(ostream &out)
double timer_report(double lasttime)
Reports the time elapsed since a given time.
void change_type(char letter)
Get the data type indicated by a single letter code.
Generalized matrix class.
Header file for general utilities.
int option_kill(Boption *option)
Deallocates a linked list of option structures.
void write(Bstring &filename)
int * matrix_find_linear_sequence(Matrix, int window)
Finds a linear sequence of elements based on a pairwise matrix.
DataType
Base data type specifier.