Problem with SetMatrixArray

[size=150]
Dear all Rooters,
I have a problem when try to use the function TMatrixD::SetMatrixArray.
The code is:

double arrarytemp;
TMatrixD MassMatrix;
arraytemp = new double[(n
n];
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
arraytemp[i*n+j] = value;
}
}
MassMatrix.SetMatrixArray(arraytemp);

Then the program simply crashed here, message is following:

*** Break *** segmentation violation
Generating stack trace…
0x0804de8a in from ./fim20
0x07c927e4 in __libc_start_main + 0xdc from /lib/libc.so.6
0x0804b591 in TObject::Execute(char const*, char const*, int*) + 0x79 from ./fim20
Aborted

what’s wrong with my code??

thanks.

[/size]

Somewhere you have to inform TMatrix about the size of the matrix.
-either call the rigth TMatrixD constructor
-or call the rigth SetMatrixArray function with the dimension parameters.

see examples of use in $ROOTSYS/test/stressLinear.cxx

Rene

[size=150]Many thanks, Rene.[/size]