Lists a 2D double matrix to the System console.
197691
public static void displayMatrix(double[][] matrix) {
        String line;
        for (int f = 0; f < matrix.length; f++) {
            line = "";
            for (int g = 0; g < matrix.length; g++) {
                line += matrix[g][f] + " | ";
            }
            logger.debug(line);
        }
    }
1145792
public static void multRow(Matrix A, int i, double c)
    {
        multRow(A, i, 0, A.cols(), c);
    }
416371
def aandb(a, b):
    """"""
    return matrix(np.logical_and(a, b).astype('float'), a.size)
1115770
def as_2d(self):
        
        if not self.isdiagonal:
            return self.x
        return np.diag(self.x.flatten())
93982
public static void diag( DMatrix2x2 input , DMatrix2 out ) {
        out.a1 = input.a11;
        out.a2 = input.a22;
    }
738950
static void computePseudo(DMatrixRMaj A , DMatrixRMaj output ) {
		final int N = A.numRows;

		DMatrix2x2 m = new DMatrix2x2();
		DMatrix2x2 m_inv = new DMatrix2x2();

		for (int i = 0, index=0; i < N; i++) {
			double a_i1 = A.data[index++];
			double a_i2 = A.data[index++];
			m.a11 += a_i1*a_i1;
			m.a12 += a_i1*a_i2;
			m.a22 += a_i2*a_i2;
		}
		m.a21 = m.a12;
		CommonOps_DDF2.invert(m,m_inv);

		output.reshape(2,N);
		for (int i = 0,index=0; i < N; i++) {
			output.data[i] = A.data[index++]*m_inv.a11 + A.data[index++]*m_inv.a12;
		}
		int end = 2*N;
		for (int i = N,A_index=0; i < end; i++) {
			output.data[i] = A.data[A_index++]*m_inv.a21 + A.data[A_index++]*m_inv.a22;
		}
	}
392679
private static double[] toArray(List<Double> list) {
    double[] values = new double[list.size()];
    for (int i = 0; i < values.length; i++) {
      values[i] = list.get(i);
    }
    return values;
  }
1000303
def get_matrices():
    
    with open('hwrt/misc/is_one_symbol_classifier.pickle', 'rb') as f:
        a = pickle.load(f)

    arrays = []
    for el1 in a.input_storage:
        for el2 in el1.__dict__['storage']:
            if isinstance(el2, cuda.CudaNdarray):
                arrays.append({'storage': numpy.asarray(el2),
                               'name': el1.name})
            else:
                logging.warning("was type %s. Do nothing." % type(el2))
                logging.debug(el1.name)
    return arrays
1243227
def do_gate_matrix(self, matrix: np.ndarray,
                       qubits: Sequence[int]) -> 'AbstractQuantumSimulator':
        
        # e.g. 2-qubit matrix is 4x4; turns into (2,2,2,2) tensor.
        tensor = np.reshape(matrix, (2,) * len(qubits) * 2)

        # Note to developers: you can use either einsum- or tensordot- based functions.
        # tensordot seems a little faster, but feel free to experiment.
        # self.wf = targeted_einsum(gate=gate_matrix, wf=self.wf, wf_target_inds=qubits)
        self.wf = targeted_tensordot(gate=tensor, wf=self.wf, wf_target_inds=qubits)
        return self
186300
function dumpMatrix( $arr, $rows, $cols )
    {
        for ( $i = 0; $i < $rows; $i++ )
        {
            for ( $j = 0; $j < $cols; $j++ )
            {
                print( $arr->get( $i, $j ) . " " );
                if ( $j == $cols-1 )
                    print( "\n" );
            }
        }
    }
324805
def display(self):
        """"""
        def render(line):
            is_wide_char = False
            for x in range(self.columns):
                if is_wide_char:  # Skip stub
                    is_wide_char = False
                    continue
                char = line[x].data
                assert sum(map(wcwidth, char[1:])) == 0
                is_wide_char = wcwidth(char[0]) == 2
                yield char

        return ["".join(render(self.buffer[y])) for y in range(self.lines)]
600535
def Ry_matrix(theta):
    """"""
    return np.array([
        [np.cos(theta), 0, np.sin(theta)],
        [0, 1, 0],
        [-np.sin(theta), 0, np.cos(theta)]
    ])
353571
public static DoubleMatrix permutationDoubleMatrixFromPivotIndices(int size, int[] ipiv) {
        int n = ipiv.length;
        //System.out.printf("size = %d n = %d\n", size, n);
        int indices[] = new int[size];
        for (int i = 0; i < size; i++)
            indices[i] = i;

        //for (int i = 0; i < n; i++)
        //    System.out.printf("ipiv[%d] = %d\n", i, ipiv[i]);

        for (int i = 0; i < n; i++) {
            int j = ipiv[i] - 1;
            int t = indices[i];
            indices[i] = indices[j];
            indices[j] = t;
        }
        DoubleMatrix result = new DoubleMatrix(size, size);
        for (int i = 0; i < size; i++)
            result.put(indices[i], i, 1.0);
        return result;
    }
943119
function Matrix() {
  var m = Array.prototype.concat.apply([], arguments);
  if (!m.length) {
    m = [
      1, 0, 0, 0,
      0, 1, 0, 0,
      0, 0, 1, 0,
      0, 0, 0, 1
    ];
  }
  this.m = hasFloat32Array ? new Float32Array(m) : m;
}
137244
def codes_get_double_array(handle, key, size):
    # type: (cffi.FFI.CData, str, int) -> T.List[float]
    
    values = ffi.new('double[]', size)
    size_p = ffi.new('size_t *', size)
    _codes_get_double_array(handle, key.encode(ENC), values, size_p)
    return list(values)
1121303
def _list2array(lst):
    """"""

    if lst and isinstance(lst[0], cp.ndarray):
        return cp.hstack(lst)
    else:
        return cp.asarray(lst)
443915
public static void printMatrix(int rows, int cols, Matrix m) {
        for(int col_num = 0; col_num < cols; col_num++) {
            for (int row_num = 0; row_num < rows; row_num++) {
                System.out.print(m.get(row_num,col_num) + " ");
            }
            System.out.print("\n");
        }
        System.out.print("\n");
    }