working with matrix

David Gillies daggillies at
Wed Apr 3 00:23:44 CEST 2013

You'll have to write your own, unless someone's already done this and
released code. With the exception of matrix division, these are fairly
simple to implement, although implementing them EFFICIENTLY is more
problematical. Division is quite a bit harder because it requires an
inversion (i.e. A/B = A B^(-1) or A\B = A^(-1) B)

The canonical way to implement a matrix is as a pointer to pointer to
element type, containing a vector of pointers to rows (or columns) of data.
Matrices can be implemented quite efficiently with C++ STL types. For
built-in types, there are subtleties to do with data locality and cache
trashing but that's likely to be less of an issue with GMP.

sketch code is something like for nxn matrix of T

T **m;
m=new T*[n];
for(int i=0;i<n;i++)
   m[i]=new T[n];

On Tue, Apr 2, 2013 at 2:44 PM, Ramón T. B. <framontb at> wrote:

> Hello,
>    how could I do for working with matrix filled with mpz_t numbers? I
> say, for doing (math) matrix multiplications for example. It is possible or
> I need another library outside de gmp?
>    I refer to those matrix operations like that (
> in the gsl library.
> Best regards and thanks in advance: framontb
> _______________________________________________
> gmp-discuss mailing list
> gmp-discuss at

David Gillies
San Jose
Costa Rica

More information about the gmp-discuss mailing list