CodeCogs - A iteractive open source Numerical library in C/C++, with wrappers for .NET and Excel Welcome... Login
Site Map
shopping cart
OSXWindowsLinux
Search CodeCogs
Numerical Components
References

Valid RSS

array

Matrix

Available under GPL (Free) and Commercial licence
get a GPL licence
COST (GBP)
this unit 0.31
sub units 0.00
add a commercial licence to your cart
0
viewed 15488 times and licensed 292 times

Dynamically allocates a zero-based 2D block (matrix) of data.

Controller: will    Contact Controller

+View version details
Contents hide toc
buy now     get GPL     add to cart

Interface

#include <codecogs/array/matrix.h>

using namespace Array;

template<class T>T** matrix (long Rows, long Columns)[inline]
Dynamically allocates a zero-based 2D block (matrix) of data.
template<class T>void free_matrix (T** Matrix)[inline]
Frees from memory a 2D block of dynamically allocated data.

Function Documentation

 
template<class T>T**matrixlongRows
longColumns )[inline]
Dynamically allocates a zero-based 2D block of memory. This memory block is continuous, and is in column then row order

1/matrix-969.png
+
Ordering of data

For example, with an allocation of the type:
float **a = matrix<float>(2,3);
Then a[1][4] === a[2][0].

The opposite of this function is free_matrix .

Example

#include <codecogs/array/matrix.h>
 
int main()
{
  // allocate some memory, 5 rows, 3 columns
  int **A = Array:matrix<int>(5,3);

// initialize with some data for(int j=0; j<5; j++) for(int i=0; i<3; i++) A[j][i] = i*j;   // convert to one-dimensional array int *B = A[0]; for(int i=0; i<15; i++) printf(" %d", B[i]);   // tidy up Array::free_matrix(A); }
Output:
1 2 3 2 4 6 3 6 9 4 8 12 5 10 15
Note:
You should always use free_matrix to de-allocate memory allocated to this structure.
Parameters:
RowsThe 2nd dimension of a matrix.
ColumnsThe 1st (primary) dimension of a matrix.
Authors:
Will Bateman (February 2005)
Source Code:

To view or download source code you need either a GPL or Commercial Licence.

buy now     get GPL     add to cart

Not a member, then Register with CodeCogs. Already a Member, then Login.

 
template<class T>voidfree_matrixT**Matrix )[inline]
Removes any dynamically allocated memory for a 2D structure from the stack. This function is usually used on data structures created using matrix<>, though it can also be used on other 2D types, so long as the memory is continuously allocated.

The opposite of this function is matrix
Parameters:
Matrixis the 2D data structure to delete.
Authors:
Will Bateman (February 2005)
Source Code:

To view or download source code you need either a GPL or Commercial Licence.

buy now     get GPL     add to cart

Not a member, then Register with CodeCogs. Already a Member, then Login.

Page Comments

Format Excel Equations

  You must login to leave a messge


Last Modified: 18 Oct 07 @ 17:07     Page Rendered: 2009-07-01 20:57:53

Valid CSS!   Valid XHTML 1.0 Transitional