code: public static Info inv( final Variable A , ManagerTempVariables manager) {
          Info ret = new Info();
  
          if( A instanceof VariableMatrix ) {
              final VariableMatrix output = manager.createMatrix();
              ret.output = output;
              ret.op = new Operation("inv-m") {
                  @Override
                  public void process() {
                      VariableMatrix mA = (VariableMatrix)A;
                      output.matrix.reshape(mA.matrix.numRows, mA.matrix.numCols);
                      if( !CommonOps_DDRM.invert(mA.matrix,output.matrix) )
                          throw new RuntimeException("Inverse failed!");
                  }
              };
          } else {
              final VariableDouble output = manager.createDouble();
              ret.output = output;
              ret.op = new Operation("inv-s") {
                  @Override
                  public void process() {
                      VariableScalar mA = (VariableScalar)A;
                      output.value = 1.0/mA.getDouble();
                  }
              };
          }
  
          return ret;
      }
docs: Matrix inverse