The Zenautics Matrix Project

2009


Sourceforge Project Page


Download Page

Version

0.07 Beta

Despite rigorous use and development since 2005, the project is considered a beta relase until sufficient feedback for the sourceforge project is available.

Quick Links to the Documentation

Introduction

This C++ Matrix/Vector Library provides a powerful software development tool for real and complex data manipulation. It is an easy to use, fast and memory efficient for one and/or two dimensional matrices. A great deal of effort in design provides elegant access to the Matrix for real data and for complex data or both. The Matrix is highly optimized for column-wise operations with real-only, complex, and mixed data. Since the double type is the most commonly used floating point type for demanding PC applications, this library is optimized and specific for type 'double' and 'stdcomplex<double>'.

Features

Professional Version

Main Package Contents




Data Access

The Matrix treated as a real-only vector:
Matrix A(10); // Create a vector (10x1).
...
double d = A[0];  // Zero based indexing of the matrix as a real-only vector.
A[1] = d*4.0;     // Set a real value in the vector.

A.PrintStdout(4); // Print A to the standard output with a precision of 4.

The Matrix treated as a real-only matrix:

Matrix A(2,2); // Create a matrix (2x2).
...
double d = A[0][0];  // Zero based indexing of the matrix as a real-only matrix.
A[0][1] = d*4.0;

The Matrix can be treated as a complex vector:

Matrix A(10); // Create a vector (10x1).
...
double d = A(0).real();  // Zero based indexing of the matrix as a complex vector.
double v = A(0).imag();
A(1) = d; // set a real value
std::complex<double> q(1.0,-2.0);
A(2) = q; // set a complex value 

or as a complex matrix:

Matrix A(2,2); // Create a matrix (2x2).
...
std::complex<double> c = B(0,0); 
double r = A(0,1).real(); 
double i = A(0,1).imag();
std::complex<double> w(1.0,-2.0);
A(1,1) = w;




Loading Matrices

For ASCII files with almost any delimiter (i.e. whitespace, comma, ';', etc), the delimiter is determined automatically. The matrix size is also determined automatically (The matrix is first loaded into a linked list. Once the matrix dimensions are known, it is then stored as a matrix. This means file data is only read once.).

e.g. "Data.txt" which is delimited by tabs.

Matrix A;
bool result;
result = A.ReadFromFile("Data.txt");

e.g. "Data.csv" which is delimited by commas.

Matrix A;
bool result;
result = A.ReadFromFile("Data.csv");

Matrices can be also stored as lossless compressed binary files.

e.g. "Data.mtx" is a compressed binary matrix file.

Matrix A;
bool result;
result = A.ReadFromFile("Data.mtx");




Outputting Matrices

Output to stdout.
Matrix A = "[ 1 2 3; 4 5 6; 7 8 9 ]"; // set the matrix from a string.
bool result;
result = A.PrintStdout();

Output to file.

Matrix A = "[ 1 2 3; 4 5 6; 7 8 9 ]"; // set the matrix from a string.
bool result;
result = A.Print("A.txt",6); // output with a precision of 6 (i.e. 6 significant digits).

Append to file.

Matrix A = "[ 1 2 3; 4 5 6; 7 8 9 ]"; // set the matrix from a string.
bool result;
result = A.Print("A.txt",6,true); // output in append mode with a precision of 6 (i.e. 6 significant digits).

Output to a lossless compressed binary file.

Matrix A = "[ 1 2 3; 4 5 6; 7 8 9 ]"; // set the matrix from a string.
bool result;
result = A.Save("A.mtx"); // save to a compressed binary using a method balanced for speed and compression efficiency.

Output to a comma delimited file.

Matrix A = "[ 1 2 3; 4 5 6; 7 8 9 ]"; // set the matrix from a string.
bool result;
result = A.PrintDelimited("A.csv",6,','); // output to a comma delimited file with a precision of 6.




Plotting Matrix Data

Matrix data can be plotted directly to a compressed (RLE) bitmap.
bool result;
Matrix X = "[ 1 2 3 4 5 6 7 8 9 10 ]"; // set the matrix from a string, row vector.
Matrix Y = X^2;
result = Plot( "testplot.bmp", "Y=X^2", "X (m)", "Y (m)", X, Y, "Y=X^2", "(m^2)" );

testplot.bmp

Equivalently, there is a member function for plotting columns of the matrix vs each other.

bool result;
X = "[ 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; ]"; // set the matrix from a string, column vector.
result = X.Concatonate( X^2 );
result = X.Plot( 0, 1, "testplot2.bmp", "Y=X^2", "X (m)", "Y (m)", "Y=X^2", "(m^2)" );

testplot2.bmp

Multiple series may be plotted with the member function.

bool result;
X = "[ 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; ]"; // set the matrix from a string, column vector.
Y = X; 
result = X.Concatonate( Y^2 );
result = X.Concatonate( Y^3 );
result = X.Plot( 0, 1, 2, "testplot3.bmp", "Y=X^2", "X (m)", "Y (m)", "Y=X^2", "(m^2)", "Y=X^3", "(m^3)" ); 

testplot3.bmp

Plotting multiple series.

X = "[ 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; ]"; // set the matrix from a string, column vector.
Matrix Y1 = X^(0.5);
Matrix Y2 = X;
Matrix Y3 = X^2; 
Matrix Y4 = X^3; 
result = Plot( "testplot4.bmp", "Y as function of X", "X (m)", "Y (m)", X, Y1, "Y=sqrt(X)", "sqrt(m)", X, Y2, "Y=(X)", "(m)", X, Y3, "Y=X^2", "(m^2)", X, Y4, "Y=X^3", "(m^3)" );

testplot4.bmp




LICENSE INFORMATION

Copyright (c) 2008, Glenn D. MacGougan, Zenautics Technologies Inc.

This license is categorized as a BSD-style license (refer http://en.wikipedia.org/wiki/Bsd_license).

Redistribution pertains to the following files and their contents.

Redistribution and use in source and binary forms, with or without modification, of the specified files is permitted provided the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.




Notes

This code was developed using rigourous unit testing for every function and operation. Despite any rigorous development process, bugs are inevitable. Please report bugs and suggested fixes to glenn at zenautics.com.




Release Notes

Version 0.01 Beta

Version 0.02 Beta

Version 0.03 Beta

Version 0.04 Beta

Version 0.05 Beta

Version 0.06 Beta

Version 0.07 Beta






FFT

The Professional Version utilizes Intel's FFT (fastest FFT available). For performance comparison of the various FFT methods refer to http://www.fftw.org/benchfft/.

The Basic Version utilizes the KISS FFT software libary (http://sourceforge.net/projects/kissfft/, also BSD license).

Kiss FFT License Information

Copyright (c) 2003-2004, Mark Borgerding

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.






Getting Started using Microsoft Visual C++ 2008 (Express Edition) (MSVC 9)

Start Microsoft Visual C++ 2008.



Select File->New->Project.



Select Win32->Win32 Console Application->Choose your project name and path.



Select Next.



Select Empty Project. Precompiled headers are not needed. Select Finish.



Your project will look something like this.



Select Source Files->Add->Existing Item...



Select the files needed for the project.



Try building the solution.



You should see output like this.



Try running the application in debug mode (Press F5).






Generated on Sun Feb 8 15:50:10 2009 for The Zenautics Matrix Project by  doxygen 1.5.4