Invert
- Note
- This tool is part of the GAMS Tools Library. Please inspect the general information about GAMS Tools.
This calculates the inverse of a square matrix A: A*AInv = I
. The matrices A
and AInv
are indexed over (i,i)
.
Usage
Command line:
gamstool [linalg.]Invert i A AInv gdxIn=fileIn.gdx gdxOut=fileOut.gdx
Compile time:
$callTool [linalg.]Invert i A AInv [gdxIn=fileIn.gdx] [gdxOut=fileOut.gdx]
Execution time:
executeTool '[linalg.]Invert i A AInv [gdxIn=fileIn.gdx] [gdxOut=fileOut.gdx]';
Where:
Argument Description i
Name of set used in matrix i(*)
.A
Name of two-dimensional matrix parameter A(i,i)
.AInv
Name of two-dimensional parameter containing the inverse AInv(i,i)
.
The following parameters are available:
Parameter Description gdxIn=fileIn.gdx
Name of GDX file that contains symbols i
andA
. Mandatory if called from the command line, otherwise optional.gdxOut=fileOut.gdx
Name of GDX file that contains symbol AInv
after execution. Mandatory if called from the command line, otherwise optional.
Example
Set i /i1*i3 /;
Alias (i,j);
Table a(i,j) 'original matrix'
i1 i2 i3
i1 1 2 3
i2 1 3 4
i3 1 4 3;
Parameter inva(i,j) 'inverse of a';
execute_unload 'a.gdx', i, a;
executeTool.checkErrorLevel 'linalg.invert i a inva -gdxIn=a.gdx -gdxOut=b.gdx';
execute_load 'b.gdx', inva;
display a, inva;