Examines the matrix structure to determine how to parameterize F.
761458
@Override
	public void encode(DMatrixRMaj F, double[] param) {
		// see if which columns are to be used
		selectColumns(F);
		
		// set the largest element in the first two columns and normalize
		// using that value
		double v[] = new double[]{F.get(0,col0),F.get(1,col0),F.get(2,col0),
				F.get(0,col1),F.get(1,col1),F.get(2,col1)};
		double divisor = selectDivisor(v,param);
		
		// solve for alpha and beta and put into param
		SimpleMatrix A = new SimpleMatrix(3,2);
		SimpleMatrix y = new SimpleMatrix(3,1);
		for( int i = 0; i < 3; i++ ) {
			A.set(i,0,v[i]);
			A.set(i,1,v[i+3]);
			y.set(i,0,F.get(i,col2)/divisor);
		}

		SimpleMatrix x = A.solve(y);
		
		param[5] = x.get(0);
		param[6] = x.get(1);
	}
712020
public void setFundamental( DMatrixRMaj F , Point3D_F64 e2 ) {
		this.F = F;
		if( e2 != null )
			this.e2.set(e2);
		else {
			MultiViewOps.extractEpipoles(F,new Point3D_F64(),this.e2);
		}
	}
1176828
public static void setMatrix(final double[][] m1, final int r0, final int r1, final int[] c, final double[][] m2) {
    assert r0 <= r1 : ERR_INVALID_RANGE;
    assert r1 <= m1.length : ERR_MATRIX_DIMENSIONS;
    for(int i = r0; i < r1; i++) {
      final double[] row1 = m1[i], row2 = m2[i - r0];
      for(int j = 0; j < c.length; j++) {
        row1[c[j]] = row2[j];
      }
    }
  }
1373493
def fmap(self, f: Callable[[T], B]) -> 'List[B]':
        
        return List([f(x) for x in self.unbox()])
67059
function dfFromMatrixHelper(matrix, startRow, colNames) {
  var nCol = colNames.size();
  var nRow = matrix.length - startRow;
  var columns = allocArray(nCol);
  var j;
  for (j = 0; j < nCol; j++) {
    columns[j] = allocArray(nRow);
  }
  for (var i = 0; i < nRow; i++) {
    var rowArray = matrix[i + startRow];
    if (rowArray.length !== nCol) {
      throw new Error('all row arrays must be of the same size');
    }
    for (j = 0; j < nCol; j++) {
      columns[j][i] = rowArray[j];
    }
  }
  return newDataFrame(columns, colNames);
}
1927
def encode_matrix_parameters(parameters):
    
    result = []

    for param in iter(sorted(parameters)):
        if isinstance(parameters[param], (list, tuple)):
            value = (';%s=' % (param)).join(parameters[param])
        else:
            value = parameters[param]

        result.append("%s=%s" % (param, value))

    return ';'.join(result)
937124
function arrayToMatrix (a) {
  return { a: a[0], b: a[1], c: a[2], d: a[3], e: a[4], f: a[5] }
}
987540
public void factorize(boolean checkSymmetry) throws Exception {
		if (checkSymmetry && !Property.TWELVE.isSymmetric(Q)) {
			throw new Exception("Matrix is not symmetric");
		}

		if(this.rescaler != null){
			double[] cn_00_original = null;
			double[] cn_2_original = null;
			double[] cn_00_scaled = null;
			double[] cn_2_scaled = null;
			if(log.isDebugEnabled()){
				cn_00_original = ColtUtils.getConditionNumberRange(new Array2DRowRealMatrix(ColtUtils.fillSubdiagonalSymmetricMatrix(Q).toArray()), Integer.MAX_VALUE);
				log.debug("cn_00_original Q before scaling: " + ArrayUtils.toString(cn_00_original));
				cn_2_original = ColtUtils.getConditionNumberRange(new Array2DRowRealMatrix(ColtUtils.fillSubdiagonalSymmetricMatrix(Q).toArray()), 2);
				log.debug("cn_2_original Q before scaling : " + ArrayUtils.toString(cn_2_original));
			}
			//scaling the Q matrix, we have:
			//Q1 = U.Q.U[T] = U.L.L[T].U[T] = (U.L).(U.L)[T] 
			//and because U is diagonal it preserves the triangular form of U.L, so
			//Q1 = U.Q.U[T] = L1.L1[T] is the new Cholesky decomposition  
			DoubleMatrix1D Uv = rescaler.getMatrixScalingFactorsSymm(Q);
			if(log.isDebugEnabled()){
				boolean checkOK = rescaler.checkScaling(ColtUtils.fillSubdiagonalSymmetricMatrix(Q), Uv, Uv);
				if(!checkOK){
					log.warn("Scaling failed (checkScaling = false)");
				}
			}
			this.Q = ColtUtils.diagonalMatrixMult(Uv, Q, Uv);
			if(log.isDebugEnabled()){
				cn_00_scaled = ColtUtils.getConditionNumberRange(new Array2DRowRealMatrix(ColtUtils.fillSubdiagonalSymmetricMatrix(Q).toArray()), Integer.MAX_VALUE);
				log.debug("cn_00_scaled Q after scaling : " + ArrayUtils.toString(cn_00_scaled));
				cn_2_scaled = ColtUtils.getConditionNumberRange(new Array2DRowRealMatrix(ColtUtils.fillSubdiagonalSymmetricMatrix(Q).toArray()), 2);
				log.debug("cn_2_scaled Q after scaling  : " + ArrayUtils.toString(cn_2_scaled));
				
				if(cn_00_original[0] < cn_00_scaled[0] || cn_2_original[0] < cn_2_scaled[0]){
					//log.info("Q: " + ArrayUtils.toString(ColtUtils.fillSubdiagonalSymmetricMatrix(Q).toArray()));
					log.warn("Problematic scaling");
					//throw new RuntimeException("Scaling failed");
				}
			}
		}

		switch (this.mode) {

		case DIAGONAL_PIVOLTING:
			pldltpt();
			break;

		case DIAGONAL_PIVOLTING_WITH_PARTIAL_PIVOTING:
			pldltptBK();
			break;

		default:
			throw new IllegalArgumentException("unknown mode " + mode);
		}
		
	}
152517
public void process(DMatrixRMaj F , @Nullable Point3D_F64 e1 , @Nullable Point3D_F64 e2 ) {

		if( !svd.decompose(F) )
			throw new RuntimeException("SVD Failed?!");

		svd.getU(U,false);
		svd.getV(V,false);
		double singular[] = svd.getSingularValues();
		SingularOps_DDRM.descendingOrder(U,false,singular,3,V,false);

		if( e2 != null )
			e2.set(U.get(0,2),U.get(1,2),U.get(2,2));
		if( e1 != null )
			e1.set(V.get(0,2),V.get(1,2),V.get(2,2));
	}
570022
def calc_ABDE_from_lamination_parameters(self):
        
        # dummies used to unpack vector results
        du1, du2, du3, du4, du5, du6 = 0, 0, 0, 0, 0, 0
        # A matrix terms
        A11,A22,A12, du1,du2,du3, A66,A16,A26 =\
            (self.h       ) * np.dot(self.matobj.u, self.xiA)
        # B matrix terms
        B11,B22,B12, du1,du2,du3, B66,B16,B26 =\
            (self.h**2/4. ) * np.dot(self.matobj.u, self.xiB)
        # D matrix terms
        D11,D22,D12, du1,du2,du3, D66,D16,D26 =\
            (self.h**3/12.) * np.dot(self.matobj.u, self.xiD)
        # E matrix terms
        du1,du2,du3, E44,E55,E45, du4,du5,du6 =\
            (self.h       ) * np.dot(self.matobj.u, self.xiE)

        self.A = np.array([[A11, A12, A16],
                           [A12, A22, A26],
                           [A16, A26, A66]], dtype=np.float64)

        self.B = np.array([[B11, B12, B16],
                           [B12, B22, B26],
                           [B16, B26, B66]], dtype=np.float64)

        self.D = np.array([[D11, D12, D16],
                           [D12, D22, D26],
                           [D16, D26, D66]], dtype=np.float64)

        # printing E acoordingly to Reddy definition for E44, E45 and E55
        self.E = np.array([[E55, E45],
                           [E45, E44]], dtype=np.float64)

        self.ABD = np.array([[A11, A12, A16, B11, B12, B16],
                             [A12, A22, A26, B12, B22, B26],
                             [A16, A26, A66, B16, B26, B66],
                             [B11, B12, B16, D11, D12, D16],
                             [B12, B22, B26, D12, D22, D26],
                             [B16, B26, B66, D16, D26, D66]], dtype=np.float64)

        # printing ABDE acoordingly to Reddy definition for E44, E45 and E55
        self.ABDE = np.array([[A11, A12, A16, B11, B12, B16, 0, 0],
                              [A12, A22, A26, B12, B22, B26, 0, 0],
                              [A16, A26, A66, B16, B26, B66, 0, 0],
                              [B11, B12, B16, D11, D12, D16, 0, 0],
                              [B12, B22, B26, D12, D22, D26, 0, 0],
                              [B16, B26, B66, D16, D26, D66, 0, 0],
                              [0, 0, 0, 0, 0, 0, E55, E45],
                              [0, 0, 0, 0, 0, 0, E45, E44]],
                               dtype=np.float64)
228737
function createMatrixFcn( d ) {
	var len = d.length,
		n = len - 1,
		fcn,
		i;

	// Code generation. Create the variables...
	fcn = 'var o=[];var ';
	for ( i = 0; i < len; i++ ) {
		fcn += 'i' + i;
		if ( i < n ) {
			fcn += ',';
		} else {
			fcn += ';';
		}
	}
	// Create the nested for loops...
	for ( i = 0; i < len; i++ ) {
		fcn += 'for(i' + i + '=0;i' + i + '<' + d[ i ] + ';i' + i + '++){';
	}
	// Create the code which accesses the nested array values and pushes them onto the flattened array.
	fcn += 'o.push(x';
	for ( i = 0; i < len; i++ ) {
		fcn += '[i' + i + ']';
	}
	fcn += ');';

	// Tidy up:
	for ( i = 0; i < len; i++ ) {
		fcn += '}';
	}
	fcn += 'return o;';

	// Create a new function:
	return new Function( 'x', fcn );
}
3155
public void iterate() {
    // build covmat out of fitting matrix by multiplying diagonal elements with
    // 1+lambda
    for(int i = 0; i < numfit; i++) {
      System.arraycopy(alpha[i], 0, covmat[i], 0, numfit);
      covmat[i][i] *= (1.0 + lambda);
    }
    // Solve the equation system (Gauss-Jordan)
    LinearEquationSystem ls = new LinearEquationSystem(covmat, beta);
    ls.solveByTotalPivotSearch();
    // update covmat with the inverse
    covmat = ls.getCoefficents();
    // and deltaparams with the solution vector
    deltaparams = ls.getRHS();
    // deltaparams = beta;
    for(int i = 0, i2 = 0; i < numparams; i++) {
      if(dofit[i]) {
        paramstry[i] = params[i] + deltaparams[i2++];
      }
    }
    double newchisq = simulateParameters(paramstry);
    // have the results improved?
    if(newchisq < chisq) {
      // TODO: Do we need a larger limit than MIN_NORMAL?
      if(lambda * 0.1 > Double.MIN_NORMAL) {
        lambda *= 0.1;
      }
      chisq = newchisq;
      // keep modified covmat as new alpha matrix
      // and da as new beta
      for(int i = 0; i < numfit; i++) {
        System.arraycopy(covmat[i], 0, alpha[i], 0, numfit);
        beta[i] = deltaparams[i];
      }
      System.arraycopy(paramstry, 0, params, 0, numparams);
    }
    else {
      // TODO: Do we need a larger limit than MAX_VALUE?
      // Does it ever make sense to go as far up?
      // Anyway, this should prevent overflows.
      if(lambda * 10 < Double.MAX_VALUE) {
        lambda *= 10;
      }
    }
  }
500524
public void process( List<DMatrixRMaj> homographies ) {
		if( assumeZeroSkew ) {
			if( homographies.size() < 2 )
				throw new IllegalArgumentException("At least two homographies are required. Found "+homographies.size());
		} else if( homographies.size() < 3 ) {
			throw new IllegalArgumentException("At least three homographies are required. Found "+homographies.size());
		}

		if( assumeZeroSkew ) {
			setupA_NoSkew(homographies);
			if( !solverNull.process(A,1,b) )
				throw new RuntimeException("SVD failed");
			computeParam_ZeroSkew();
		} else {
			setupA(homographies);
			if( !solverNull.process(A,1,b) )
				throw new RuntimeException("SVD failed");
			computeParam();
		}
		if(MatrixFeatures_DDRM.hasUncountable(K)) {
			throw new RuntimeException("Failed!");
		}
	}
170930
def _affine_mult(c:FlowField,m:AffineMatrix)->FlowField:
    ""
    if m is None: return c
    size = c.flow.size()
    h,w = c.size
    m[0,1] *= h/w
    m[1,0] *= w/h
    c.flow = c.flow.view(-1,2)
    c.flow = torch.addmm(m[:2,2], c.flow,  m[:2,:2].t()).view(size)
    return c
1241923
private void calMatrix() throws StructureException
	{
		int     i, j;
		double  dis;
		for(i = 0; i < pro1Len; i ++)   {
			for(j = 0; j < pro2Len; j ++)   {
				dis = Calc.getDistance(cod1[i],cod2[j]);

				if(dis < Dc) {
					sij[i][j] = Dc - dis;
				}
				else  {
					sij[i][j] = 0;
				}
			}
		}
	}
885882
private boolean findFixedParameters(List<Parameter> parameters, Node cur) {
    boolean anyMovable = false;
    int index = 0;
    while (cur != null) {
      Parameter p;
      if (index >= parameters.size()) {
        p = new Parameter(cur, false);
        parameters.add(p);
        setParameterSideEffectInfo(p, cur);
      } else {
        p = parameters.get(index);
        if (p.shouldRemove()) {
          Node value = p.getArg();
          if (!cur.isEquivalentTo(value)) {
            p.setShouldRemove(false);
          } else {
            anyMovable = true;
          }
        }
      }

      cur = cur.getNext();
      index++;
    }

    for (; index < parameters.size(); index++) {
      parameters.get(index).setShouldRemove(false);
    }

    return anyMovable;
  }
88422
protected void computeInitialFeasibleSolution() {
        for (int j = 0; j < dim; j++) {
            labelByJob[j] = Double.POSITIVE_INFINITY;
        }
        for (int w = 0; w < dim; w++) {
            for (int j = 0; j < dim; j++) {
                if (costMatrix[w][j] < labelByJob[j]) {
                    labelByJob[j] = costMatrix[w][j];
                }
            }
        }
    }