Matrix Library 1.1

Why use Matrix Library?

Matrix library defines one of the most famous mathematical type: matrices. It's designed and programmed for C++ programming language. C++ actually does not have built-in type for matrices. So this library is for that reason. This library defines the a matrice type that you can use in your programs to have matrices "at will". It lets you instantiate, add, subtract, and multiply matrices easily. This page is dedicated to this library and its uses. It has a full documentation (below) of how to use it.


Getting started with the zipped file

You can download the zipped file here. You should extract the zipped folder and put it somehwere easy to reach on your computer, on your desktop, for example.


Plugging the library and the Header files in your compiler

Note: The following steps are based on Microsoft Visual Studio 2005 professional edition, you should not have any problems with the previous versions.

1)First we have to import the library file, which is name matrix, and is type of: Object File Library. To do so, open Microsoft Visual Studio. In the solution menu, right clich the resource folder >> Add >> Existing item

2)Select the location where your files are, if the library file does not appear, make sure you change "Files of type" box to "All". Select the library file and click add. You shoul see it added under Resource Files. Note: if you get warning message about adding new type, don't worry, cancel it for now.

3)Following the very first step, right click Header Files, Add >> Existing Item. Select the location where your header file is, which is type of: C/C++ Header File. You should see it under the Header Files.

4)Now you have everything plugged in! Congratulations. See the functions below to learn how actually use the files.


Using the library functions

1)Including the header file in your code:

You should include the header file first in your code

#include "matrix.h"


2)Instantiating a matrice:

It's very easy to make a matrice, just as if you were instantiating built-in types. The type is Matrix

Matrix matrice;


3)Building the matrice:

You can build (fill in the entries) of your matrice by a function called build, that gets two parameters

Matrix matrice;
matrice.build(/*number of rows*/, /*number of columns*/);


4)Destroying the matrice (if necessary):

You can free the memory the matrice uses manually by calling the destroying function like this:

Matrix matrice;
matrice.destroy();
Note: No memory is consumed when just instantiating matrice. Actually the program will know if the matrice has any data consuming memory to free it


5)Assigning one matrice to another one:

You can assign one matrice to another by simply adding the assignment operator

Matrix matrice;
Matrix matrice1;
matrice = matrice1;


6)Multiplication:

Two matrices can be easily multiplied after building them. Note: You don't have ever to build the result matrice

Matrix matrice;
Matrix matrice1;
//After building matrice and matrice1, you can easily multiply
Matrix result;
result = matrice * matrice1;


7)Addition

Two matrices can be easily added after building them. Note: You don't have ever to build the result matrice

Matrix matrice;
Matrix matrice1;
//After building matrice and matrice1, you can easily add
Matrix result;
result = matrice + matrice1;


8)Subtraction

Two matrices can be easily subtract after building them. Note: You don't have ever to build the result matrice

Matrix matrice;
Matrix matrice1;
//After building matrice and matrice1, you can easily subtract
Matrix result;
result = matrice - matrice1;


9)Printing

It's every to print a matrice, by a function called print, like this:

Matrix matrice;
//After building 
matrice.print();


10)Resizing

It's possible to resize your matrice, the resizing function takes two parameters

Matrix matrice;
//After building 
matrice.resize(/*New rows*/, /*new columns*/);


11)Getting number of rows

It's very important in your program sometimes to know the rows of your matrice, by calling this function

Matrix matrice;
int rows = matrice.getr();


12)Getting number of columns

It's very important in your program sometimes to know the columns of your matrice, by calling this function

Matrix matrice;
int columns = matrice.getc();


13)About

To be up-to-date with the library, you can check what version you have and the credits, by calling this function

Matrix matrice;
matrice.about();