This example shows how to invert a non sparse matrix of 500x500
elements of type VpFCartesian (complex number in Cartesian
co-ordinates with fields of type real.
The WFC matrix is initialized with the values of the Fourier transformation and its inverse is compared to the known result placed in WFCI.
The distance between the inverse and the known result is displayed.
The $PrintM statement is commented out in order to show its syntax in
case it is needed, but not to produce over 250,000 lines of output given that
the matrix has 500x500 elements.
Note: This example runs only on Linux and Solaris platforms, using FinSim version 10_0_0 or any subsequent version.
module top;
`define mod(val, n) (val - (val/n)*n)
parameter SIZE = 500;
VpFCartesian WFC[SIZE-1:0][SIZE-1:0], WFCI[SIZE-1:0][SIZE-1:0];
real phi0, distance;
integer i, j, mone;
initial begin
mone = -1;
phi0 = 2*$Pi/SIZE;
$display("phi0 = %e\n", phi0);
$InitM(WFC, $VpCos(phi0*`mod($I1*$I2, SIZE)),
$VpSin(phi0*`mod($I1*$I2, SIZE)));
$InitM(WFCI, $VpCos(phi0*`mod($I1*$I2, SIZE))/SIZE,
-$VpSin(phi0*`mod($I1*$I2, SIZE))/SIZE);
WFC = WFC**(mone);
/* $PrintM(WFC, "%e");*/
distance = $VpDistAbsMax(WFC, WFCI);
$display("distance = %e\n", distance);
end
endmodule