Important facts about commercial licenses

  • Licenses are perpetual. They do not expire and do not need to be renewed.
  • Licenses can be upgraded. You can upgrade to a more expensive license later paying only the difference in cost.
  • Pay attention to the distribution type - Hosted (sites / servers), binary (applications) or source (includes all the others). Choose according to your needs (more below).
  • All licenses allow commercial use unless otherwise indicated.
  • Read the full license by clicking on the icon.
  • Read more about licenses in our handy license guide.
$5

Developer License

Unlimited projects Source and binary distribution
You need to log-in or create an account
  • Create an account
  • Log-in
  • Please use your real name.
  • Account activation link will be sent to this address.
  • Minimum 8 characters

Clicking this button confirms you read and agreed to the terms of use and privacy policy.

  • Released: Jun 1, 2011
    Last Update: Aug 29, 2011
  • Language: C/C++
  • Category: Performance

General use matrix class NxM dimensions

General use matrix class NxM dimensions
Developed by Asmir Avdicevic, Released Jun 1, 2011

A general and extensible matrix class made to handle any dimensions with speed yet providing flexibility, ease of use and portability.

C/C++

Tags: algorithm , c++ , matrix , performance

The class is meant to be light-weight, efficient and portable so only basic matrix operations were implemented needed for graphic processing, game development or similar. Typical math and rarely used operations like finding the inverse , determinant or eigenvalues of the matrix have been omitted not to clog up the class. It's built to be compiler and platform agnostic to be portable. The focus was set on ease of use and therefore features a rich function list.

Example usage:

//Multiple declarations made for easy usage
matrix a;//Declares a matrix
matrix a(5,10);//Declares a matrix and sets it to the provided dimensions
matrix a(2.5,3,3.5,4);//Declares a 2x2 matrix with initial values
matrix a(2.5,3,3.5,2.5,3,3.5,2.5,3,3.5);//Declares a 3x3 matrix with initial values

//If you want to change or initialize a matrix to some dimensions
matrix a;
a.create(5,10);
//If you want to clear the matrix and free memory
a.clear();

//Given an already declared matrix , you can populate it with data in various ways
matrix a;
a.populate(2.5,3,3.5,4);//Creates a 2x2 matrix and populates it
a.populate(2.5,3,3.5,2.5,3,3.5,2.5,3,3.5);//Creates a 3x3 matrix and initializes it

double data[2*3]={1.2,2.3,3.4,4.5,5.6,6.7};
a.populate(2,3,data);//Populates a NxM matrix with the provided data

a.create(2,3);
a.populate(data);//Populates an already formed matrix with the provided data

//Getting and setting individual data is just as simple
a.num_rows();//Returns the number of rows
a.num_columns();//Returns the number of columns
a.get_element(2,3);//Gets the element at the specified location , note that indexes go [0,n-1] and not [1,n]
a.set_element(2,3,3.5);//Sets the element at the specified location to the provided value

//Operations with matrixes using overloaded operators
matrix a,b,c;
a=b;
a=b*c;
a*=b;
a=b+c;
a=b-c;
a+=b;
a-=b;
a=b*5.3;//Multiplication by scalar
a*=5*3;
a=b/5.3;//Division by scalar
a/=5.3;
a=b+5;//Add a constant to all elements
a=b-5;//Subtract a constant from all elements
a+=5;
a-=5;
a.identity();//if the matrix is square it gets set to an identity matrix
a.identity(5);//Sets an identity matrix of dimensions NxN
a.zero();//Zeroes out the current matrix
a.zero(5,10);//Creates a matrix of size 5,10 set with 0 for each element
a.transpose();//Transposes the current matrix
a.return_transpose();//Returns the transposed matrix leaving the original matrix unchanged

//Logic operations
matrix a,b;
a==b;//Returns true on equality otherwise false
a!=b;//Returns false on equality otherwise true

To use the matrix simply include the header file and use it. It isn't suggested to use matrices with sizes larger of 5000x5000 since it requires about 190 MB of RAM and for some operations double that amount.

User Reviews

No reviews have been submitted yet.

Questions & Comments


Or enter your name and Email
No comments have been posted yet.
You must be logged-in to vote. Log-in to your account or register now.