public void getFeature3D(int featureIdx, Point3D_F64 X) { int row = featureIdx*3; X.x = B.unsafe_get(row,0); X.y = B.unsafe_get(row+1,0); X.z = B.unsafe_get(row+2,0); }
/** * Extracts a column from the camera matrix and puts it into the geometric 3-tuple. */ public static void extractColumn(DMatrixRMaj P, int col, GeoTuple3D_F64 a) { a.x = P.unsafe_get(0,col); a.y = P.unsafe_get(1,col); a.z = P.unsafe_get(2,col); }
@Override public void getDiagonal(double[] diag, double[] off) { diag[0] = B.get(0); for( int i = 1; i < n; i++ ) { diag[i] = B.unsafe_get(i,i); off[i-1] = B.unsafe_get(i-1,i); } }
@Override public void getDiagonal(double[] diag, double[] off) { diag[0] = UBV.get(0); for( int i = 1; i < n; i++ ) { diag[i] = UBV.unsafe_get(i,i); off[i-1] = UBV.unsafe_get(i-1,i); } }
/** * <p> * Checks to see if a matrix is lower triangular or Hessenberg. A Hessenberg matrix of degree N * has the following property:<br> * <br> * a<sub>ij</sub> ≤ 0 for all i < j+N<br> * <br> * A triangular matrix is a Hessenberg matrix of degree 0. * </p> * @param A Matrix being tested. Not modified. * @param hessenberg The degree of being hessenberg. * @param tol How close to zero the lower left elements need to be. * @return If it is an upper triangular/hessenberg matrix or not. */ public static boolean isLowerTriangle(DMatrixRMaj A , int hessenberg , double tol ) { for( int i = 0; i < A.numRows-hessenberg-1; i++ ) { for( int j = i+hessenberg+1; j < A.numCols; j++ ) { if( !(Math.abs(A.unsafe_get(i,j)) <= tol) ) { return false; } } } return true; }
/** * <p> * Checks to see if a matrix is upper triangular or Hessenberg. A Hessenberg matrix of degree N * has the following property:<br> * <br> * a<sub>ij</sub> ≤ 0 for all i < j+N<br> * <br> * A triangular matrix is a Hessenberg matrix of degree 0. * </p> * @param A Matrix being tested. Not modified. * @param hessenberg The degree of being hessenberg. * @param tol How close to zero the lower left elements need to be. * @return If it is an upper triangular/hessenberg matrix or not. */ public static boolean isUpperTriangle(DMatrixRMaj A , int hessenberg , double tol ) { for( int i = hessenberg+1; i < A.numRows; i++ ) { int maxCol = Math.min(i-hessenberg, A.numCols); for( int j = 0; j < maxCol; j++ ) { if( !(Math.abs(A.unsafe_get(i,j)) <= tol) ) { return false; } } } return true; }
X[i] = nullspace.unsafe_get(i,0); Y[i] = nullspace.unsafe_get(i,1); Z[i] = nullspace.unsafe_get(i,2); W[i] = nullspace.unsafe_get(i,3);
public void getCameraMatrix(int viewIdx, DMatrixRMaj P) { DMatrixRMaj H = homographies.get(viewIdx); int row = totalFeatures*3 + viewIdx*3; tmp.x = B.unsafe_get(row,0); tmp.y = B.unsafe_get(row+1,0); tmp.z = B.unsafe_get(row+2,0); N.remove(tmp); CommonOps_DDRM.insert(H,P,0,0); P.set(0,3, tmp.x); P.set(1,3, tmp.y); P.set(2,3, tmp.z); }
int x1 = (j+1)*gridWidth/numCategories; double value = confusion.unsafe_get(i,j);
/** * Writes the upper triangular matrix into the specified matrix. * * @param upper Where the upper triangular matrix is writen to. */ @Override public DMatrixRMaj getUpper(DMatrixRMaj upper ) { int numRows = LU.numRows < LU.numCols ? LU.numRows : LU.numCols; int numCols = LU.numCols; upper = UtilDecompositons_DDRM.checkZerosLT(upper,numRows,numCols); for( int i = 0; i < numRows; i++ ) { for( int j = i; j < numCols; j++ ) { upper.unsafe_set(i,j, LU.unsafe_get(i,j)); } } return upper; }
@Override public DMatrixRMaj getT(DMatrixRMaj T ) { // write the values to T if( lower ) { T = UtilDecompositons_DDRM.checkZerosUT(T,n,n); for( int i = 0; i < n; i++ ) { for( int j = 0; j <= i; j++ ) { T.unsafe_set(i,j,this.T.unsafe_get(i,j)); } } } else { T = UtilDecompositons_DDRM.checkZerosLT(T,n,n); for( int i = 0; i < n; i++ ) { for( int j = i; j < n; j++ ) { T.unsafe_set(i,j,this.T.unsafe_get(i,j)); } } } return T; }
/** * <p> * Extracts the diagonal elements 'src' write it to the 'dst' vector. 'dst' * can either be a row or column vector. * <p> * * @param src Matrix whose diagonal elements are being extracted. Not modified. * @param dst A vector the results will be written into. Modified. */ public static void extractDiag(DMatrixRMaj src, DMatrixRMaj dst ) { int N = Math.min(src.numRows, src.numCols); if( !MatrixFeatures_DDRM.isVector(dst) || dst.numCols*dst.numCols != N ) { dst.reshape(N,1); } for( int i = 0; i < N; i++ ) { dst.set( i , src.unsafe_get(i,i) ); } }
/** * Writes the lower triangular matrix into the specified matrix. * * @param lower Where the lower triangular matrix is written to. */ @Override public DMatrixRMaj getLower(DMatrixRMaj lower ) { int numRows = LU.numRows; int numCols = LU.numRows < LU.numCols ? LU.numRows : LU.numCols; lower = UtilDecompositons_DDRM.checkZerosUT(lower,numRows,numCols); for( int i = 0; i < numCols; i++ ) { lower.unsafe_set(i,i,1.0); for( int j = 0; j < i; j++ ) { lower.unsafe_set(i,j, LU.unsafe_get(i,j)); } } if( numRows > numCols ) { for( int i = numCols; i < numRows; i++ ) { for( int j = 0; j < numCols; j++ ) { lower.unsafe_set(i,j, LU.unsafe_get(i,j)); } } } return lower; }
ub += (u[i] = QR.unsafe_get(i,n))*a[i];
for( int y = 0; y < expected.numRows; y++ ) { for( int x = 0; x < expected.numCols; x++ ) { double diff = Math.abs(found.unsafe_get(y,x)-expected.unsafe_get(y,x)); if( diff > tol ) {
for( int y = 0; y < expected.numRows; y++ ) { for( int x = 0; x < expected.numCols; x++ ) { double diff = Math.abs(found.unsafe_get(y,x)-expected.unsafe_get(y,x)); if( diff > tol ) {
double m = Math.sqrt(singularValues[1])*magicNumber; double vx = V.unsafe_get(0, i)*m; double vy = V.unsafe_get(1, i)*m; double vz = V.unsafe_get(2, i)*m;
double a_left = R2.unsafe_get(i,col); double a_right = T2.getIdx(i); T.data[index++] = a_left*T3.getIdx(j) - a_right*R3.unsafe_get(j,col);
/** * Constructs the linear system which is to be solved. * * sum a_ij*x_j - a_ij*u_i*z_j = 0 * sum a_ij*y_j - a_ij*v_i*z_j = 0 * * where (x,y,z) is the control point to be solved for. * (u,v) is the observed normalized point * */ protected static void constructM(List<Point2D_F64> obsPts, DMatrixRMaj alphas, DMatrixRMaj M) { int N = obsPts.size(); M.reshape(3*alphas.numCols,2*N,false); for( int i = 0; i < N; i++ ) { Point2D_F64 p2 = obsPts.get(i); int row = i*2; for( int j = 0; j < alphas.numCols; j++ ) { int col = j*3; double alpha = alphas.unsafe_get(i, j); M.unsafe_set(col, row, alpha); M.unsafe_set(col + 1, row, 0); M.unsafe_set(col + 2, row, -alpha * p2.x); M.unsafe_set(col , row + 1, 0); M.unsafe_set(col + 1, row + 1, alpha); M.unsafe_set(col + 2, row + 1, -alpha * p2.y); } } }
R.unsafe_set(i,j,QR.unsafe_get(j,i));