Ejemplo n.º 1
0
 /// <exception cref="fastmath.exceptions.NotInvertableException"/>
 public virtual fastmath.DoubleColMatrix invert()
 {
     fastmath.IntVector  pivots    = new fastmath.IntVector(getRowCount());
     com.sun.jna.Pointer rowCount  = newIntParam(getRowCount());
     com.sun.jna.Pointer colCount  = newIntParam(getColCount());
     fastmath.IntVector  output    = new fastmath.IntVector(1);
     com.sun.jna.Pointer outBuffer = com.sun.jna.Native.getDirectBufferPointer(output.
                                                                               getBuffer());
     com.sun.jna.Pointer pivotBuffer = com.sun.jna.Native.getDirectBufferPointer(pivots
                                                                                 .getBuffer());
     fastmath.LAPACK.instance.dgetrf_(rowCount, colCount, getPointer(), rowCount, pivotBuffer
                                      , outBuffer);
     if (output.elementAt(0) > 0)
     {
         throw new fastmath.exceptions.NotInvertableException(output.elementAt(0));
     }
     else
     {
         if (output.elementAt(0) < 0)
         {
             throw new System.ArgumentException("the " + -output.elementAt(0) + "-th argument had an illegal value"
                                                );
         }
     }
     fastmath.Vector     workspace = new fastmath.Vector(1024);
     com.sun.jna.Pointer lwork     = newIntParam(workspace.size);
     fastmath.LAPACK.instance.dgetri_(rowCount, getPointer(), rowCount, pivotBuffer, workspace
                                      .getPointer(), lwork, outBuffer);
     if (output.elementAt(0) > 0)
     {
         throw new fastmath.exceptions.NotInvertableException(output.elementAt(0));
     }
     else
     {
         if (output.elementAt(0) < 0)
         {
             throw new System.ArgumentException("the " + -output.elementAt(0) + "-th argument had an illegal value"
                                                );
         }
     }
     return(this);
 }