Returns a copy of the matrix with elements set to the given value if they differ from it by less than Sylvester.precision
504652
function(x) {
            	return this.map(function(p) {
            	    return (Math.abs(p - x) <= sylvester.precision) ? x : p;
            	});
                }
838500
@Override
    public DMatrixRMaj getR(DMatrixRMaj R, boolean compact) {
        if( R == null ) {
            if( compact ) {
                R = new DMatrixRMaj(minLength,numCols);
            } else
                R = new DMatrixRMaj(numRows,numCols);
        } else {
            if( compact ) {
                R.reshape(minLength,numCols);
            } else {
                R.reshape(numRows,numCols);
            }

            for( int i = 0; i < R.numRows; i++ ) {
                int min = Math.min(i,R.numCols);
                for( int j = 0; j < min; j++ ) {
                    R.unsafe_set(i,j,0);
                }
            }
        }

        for( int i = 0; i < R.numRows; i++ ) {
            for( int j = i; j < R.numCols; j++ ) {
                R.unsafe_set(i,j,QR.unsafe_get(j,i));
            }
        }


        return R;
    }
1190259
function mpn_copyi(r, s, l) {
	for (var i = 0; i < l; ++i) {
		r[i] = s[i];
	}
}
1234461
@Override
    public Matrix<T> repmat(final int rowRepeats, final int colRepeats) {
        N.checkArgument(rowRepeats > 0 && colRepeats > 0, "rowRepeats=%s and colRepeats=%s must be bigger than 0", rowRepeats, colRepeats);

        final T[][] c = N.newArray(arrayType, rows * rowRepeats);

        for (int i = 0, len = c.length; i < len; i++) {
            c[i] = N.newArray(componentType, cols * colRepeats);
        }

        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < colRepeats; j++) {
                N.copy(a[i], 0, c[i], j * cols, cols);
            }
        }

        for (int i = 1; i < rowRepeats; i++) {
            for (int j = 0; j < rows; j++) {
                N.copy(c[j], 0, c[i * rows + j], 0, c[j].length);
            }
        }

        return new Matrix<T>(c);
    }
1312110
private int[] nArgMin(int n, double[] values, int startIdx, int endIdx){
		int indices[] = new int[n];
		for (int i=0; i<n; i++){
			double minValue = Double.MAX_VALUE;
			for (int j=startIdx; j<endIdx+1; j++){
				if (values[j] < minValue){
					boolean alreadyUsed = false;
					for (int k=0; k<i; k++){
						if (indices[k]==j){
							alreadyUsed = true;
						}
					}
					if (!alreadyUsed){
						indices[i] = j;
						minValue = values[j];
					}
				}
			}
		}
		return indices;
	}
952726
def is_same_transform(matrix0, matrix1):
    
    matrix0 = np.array(matrix0, dtype=np.float64, copy=True)
    matrix0 /= matrix0[3, 3]
    matrix1 = np.array(matrix1, dtype=np.float64, copy=True)
    matrix1 /= matrix1[3, 3]
    return np.allclose(matrix0, matrix1)
23011
private static int bisect(int[] array, double value) {
        int pos = 0;
        for (int element : array) {
            if (value < element)
                break;
            pos++;
        }
        return pos;
    }
1111428
public static BasicSymmetricalDistanceMatrix cloneDM(
			BasicSymmetricalDistanceMatrix distM) {

		int n = distM.getSize();
		BasicSymmetricalDistanceMatrix cloneDM =
				new BasicSymmetricalDistanceMatrix(n);

		for (int i = 0; i < n; i++) {
			cloneDM.setIdentifier(i, distM.getIdentifier(i));
			for (int j = i + 1; j < n; j++) {
				cloneDM.setValue(i, j, distM.getValue(i, j));
			}
		}
		return cloneDM;
	}
163638
def mkron(a, *args):
    """"""
    if not isinstance(a, list):
        a = [a]
    a = list(a)  # copy list
    for i in args:
        if isinstance(i, list):
            a.extend(i)
        else:
            a.append(i)

    c = _vector.vector()
    c.d = 0
    c.n = _np.array([], dtype=_np.int32)
    c.r = _np.array([], dtype=_np.int32)
    c.core = []

    for t in a:
        thetensor = t.tt if isinstance(t, _matrix.matrix) else t
        c.d += thetensor.d
        c.n = _np.concatenate((c.n, thetensor.n))
        c.r = _np.concatenate((c.r[:-1], thetensor.r))
        c.core = _np.concatenate((c.core, thetensor.core))

    c.get_ps()
    return c
1338591
def check_precomputed_distance_matrix(X):
    
    tmp = X.copy()
    tmp[np.isinf(tmp)] = 1
    check_array(tmp)
66778
public Matrix3 set (double[] values) {
        return set(values[0], values[1], values[2],
                   values[3], values[4], values[5],
                   values[6], values[7], values[8]);
    }
1084142
function(_matrix){
            var _obj = {};
            if (_reg0.test(_matrix||'')){
                // 11,12,21,22,41,42
                _u._$forEach(
                    RegExp.$1.split(_reg1),
                    function(_value,_index){
                        _obj[_list[_index]] = _value;
                    }
                );
            }
            return _obj;
        }
370846
function(n, m, x){
  var matrix = [];
  for(var i = 0; i < n; i++) {
    matrix[i] = new Array(m);

    if(x != null){
      for(var j = 0; j < m; j++){
        matrix[i][j] = x;
      }
    }
  }

  return matrix;
}
1172695
public static void square( DMatrix1Row mat )
    {
        int index = 1;
        int indexEnd = mat.numCols;
        for( int i = 0; i < mat.numRows;
             i++ , index += i+1 , indexEnd += mat.numCols ) {
            int indexOther = (i+1)*mat.numCols + i;
            for( ; index < indexEnd; index++, indexOther += mat.numCols) {
                double val = mat.data[ index ];
                mat.data[ index ] = mat.data[ indexOther ];
                mat.data[indexOther] = val;
            }
        }
    }
516636
function setValue2fm( gl, v ) {

	var cache = this.cache;
	var elements = v.elements;

	if ( elements === undefined ) {

		if ( arraysEqual( cache, v ) ) return;

		gl.uniformMatrix2fv( this.addr, false, v );

		copyArray( cache, v );

	} else {

		if ( arraysEqual( cache, elements ) ) return;

		mat2array.set( elements );

		gl.uniformMatrix2fv( this.addr, false, mat2array );

		copyArray( cache, elements );

	}

}
410184
def confine(x,low,high):
    ''''''

    y=x.copy()
    y[y < low] = low
    y[y > high] = high
    return y
892141
def _linearInterpolationTransformMatrix(matrix1, matrix2, value):
    
    return tuple(_interpolateValue(matrix1[i], matrix2[i], value) for i in range(len(matrix1)))