Reshapes x into a matrix with input_dim columns
324214
def reshape(x,input_dim):
    '''
    

    '''
    x = np.array(x)
    if x.size ==input_dim:
        x = x.reshape((1,input_dim))
    return x
503565
def _reshape_n_vecs(self):
        """"""

        lst = []
        sl = slice(None, None, None)
        lst.append(self.__getitem__((sl, 0)))
        for m in xrange(1, self.mmax + 1):
            lst.append(self.__getitem__((sl, -m)))
            lst.append(self.__getitem__((sl, m)))
        return lst
665922
public static void convert(DMatrix input , FMatrix output ) {
        if( input.getNumRows() != output.getNumRows() )
            throw new IllegalArgumentException("Number of rows do not match");
        if( input.getNumCols() != output.getNumCols() )
            throw new IllegalArgumentException("Number of columns do not match");

        for( int i = 0; i < input.getNumRows(); i++  ) {
            for( int j = 0; j < input.getNumCols(); j++ ) {
                output.unsafe_set(i,j, (float)input.unsafe_get(i,j));
            }
        }
    }
756220
public static FloatMatrix normalizeRows(FloatMatrix x) {
                FloatMatrix temp = new FloatMatrix(x.columns);
		for (int r = 0; r < x.rows; r++)
			x.putRow(r, normalize(x.getRow(r, temp)));
		return x;
	}
612886
def ExpandDims(a, dim):
    
    shape = list(a.shape)
    if dim >= 0:
        shape.insert(dim, 1)
    else:
        shape.insert(len(shape) + dim + 1, 1)
    return np.copy(a).reshape(*shape),
49143
def _tf_flatten_batch_dims(x, num_nonbatch_dims):
  
  shape = x.shape.as_list()
  assert None not in shape
  new_shape = ([list_product(shape[:-num_nonbatch_dims])]
               + shape[-num_nonbatch_dims:])
  if new_shape != shape:
    x = tf.reshape(x, new_shape)
  return x
842921
def reshape(attrs, inputs, proto_obj):
    """"""
    if len(inputs) == 1:
        return 'reshape', attrs, inputs[0]
    reshape_shape = list(proto_obj._params[inputs[1].name].asnumpy())
    reshape_shape = [int(i) for i in reshape_shape]
    new_attrs = {'shape': reshape_shape}
    return 'reshape', new_attrs, inputs[:1]
89704
function fillMatrix(id, t, l, w, h) {
                for (var y = t; y < t + h;) {
                    for (var x = l; x < l + w;) {
                        matrix[y + '-' + x] = id;
                        ++x > maxX && (maxX = x);
                    }
                    ++y > maxY && (maxY = y);
                }
            }
750037
def transform(self, x, warn=True):
        
        # 1. split across last dimension
        # 2. re-use ranges
        # 3. Merge
        array_list = [encodeSplines(x[..., i].reshape((-1, 1)),
                                    n_bases=self.n_bases,
                                    spline_order=self.degree,
                                    warn=warn,
                                    start=self.data_min_[i],
                                    end=self.data_max_[i]).reshape(x[..., i].shape + (self.n_bases,))
                      for i in range(x.shape[-1])]
        return np.stack(array_list, axis=-2)
984774
function blockMult(a, b, rows, cols) {
                            // For small matrices, resort to naive multiplication.
                            if (rows <= 512 || cols <= 512) {
                                return a.mmul(b); // a is equivalent to this
                            }

                            // Apply dynamic padding.
                            if ((rows % 2 === 1) && (cols % 2 === 1)) {
                                a = embed(a, rows + 1, cols + 1);
                                b = embed(b, rows + 1, cols + 1);
                            } else if (rows % 2 === 1) {
                                a = embed(a, rows + 1, cols);
                                b = embed(b, rows + 1, cols);
                            } else if (cols % 2 === 1) {
                                a = embed(a, rows, cols + 1);
                                b = embed(b, rows, cols + 1);
                            }

                            var halfRows = parseInt(a.rows / 2);
                            var halfCols = parseInt(a.columns / 2);
                            // Subdivide input matrices.
                            var a11 = a.subMatrix(0, halfRows - 1, 0, halfCols - 1);
                            var b11 = b.subMatrix(0, halfRows - 1, 0, halfCols - 1);

                            var a12 = a.subMatrix(0, halfRows - 1, halfCols, a.columns - 1);
                            var b12 = b.subMatrix(0, halfRows - 1, halfCols, b.columns - 1);

                            var a21 = a.subMatrix(halfRows, a.rows - 1, 0, halfCols - 1);
                            var b21 = b.subMatrix(halfRows, b.rows - 1, 0, halfCols - 1);

                            var a22 = a.subMatrix(halfRows, a.rows - 1, halfCols, a.columns - 1);
                            var b22 = b.subMatrix(halfRows, b.rows - 1, halfCols, b.columns - 1);

                            // Compute intermediate values.
                            var m1 = blockMult(Matrix.add(a11, a22), Matrix.add(b11, b22), halfRows, halfCols);
                            var m2 = blockMult(Matrix.add(a21, a22), b11, halfRows, halfCols);
                            var m3 = blockMult(a11, Matrix.sub(b12, b22), halfRows, halfCols);
                            var m4 = blockMult(a22, Matrix.sub(b21, b11), halfRows, halfCols);
                            var m5 = blockMult(Matrix.add(a11, a12), b22, halfRows, halfCols);
                            var m6 = blockMult(Matrix.sub(a21, a11), Matrix.add(b11, b12), halfRows, halfCols);
                            var m7 = blockMult(Matrix.sub(a12, a22), Matrix.add(b21, b22), halfRows, halfCols);

                            // Combine intermediate values into the output.
                            var c11 = Matrix.add(m1, m4);
                            c11.sub(m5);
                            c11.add(m7);
                            var c12 = Matrix.add(m3, m5);
                            var c21 = Matrix.add(m2, m4);
                            var c22 = Matrix.sub(m1, m2);
                            c22.add(m3);
                            c22.add(m6);

                            //Crop output to the desired size (undo dynamic padding).
                            var resultat = Matrix.zeros(2 * c11.rows, 2 * c11.columns);
                            resultat = resultat.setSubMatrix(c11, 0, 0);
                            resultat = resultat.setSubMatrix(c12, c11.rows, 0);
                            resultat = resultat.setSubMatrix(c21, 0, c11.columns);
                            resultat = resultat.setSubMatrix(c22, c11.rows, c11.columns);
                            return resultat.subMatrix(0, rows - 1, 0, cols - 1);
                        }
897987
def _idx_col2rowm(d):
    """"""
    if 0 == len(d):
        return 1
    if 1 == len(d):
        return np.arange(d[0])
    # order='F' indicates column-major ordering
    idx = np.array(np.arange(np.prod(d))).reshape(d, order='F').T
    return idx.flatten(order='F')
118480
function subMatrix (data, numRows, numCols, row, col) {
  var sub = []

  for (var i = 0; i < numRows; i++) {
    for (var j = 0; j < numCols; j++) {
      if ((i !== row) && (j !== col)) {
        sub.push(data[matrixToArrayIndex(i, j, numCols)])
      }
    }
  }

  return sub
}
576669
function flatten(matrix) {
    const res = [];

    // If the given matrix is not a matrix but a scalar.
    if (!Array.isArray(matrix)) {
        matrix = [
            [matrix]
        ];
    }

    matrix.forEach((row) => {
        // If the given matrix is a vector.
        if (!Array.isArray(row)) {
            row = [row];
        }

        row.forEach((elem) => {
            res.push(elem.real);
            res.push(elem.imag);
        });
    });
    return res;
}
843494
function embed(mat, rows, cols) {
                            var r = mat.rows;
                            var c = mat.columns;
                            if ((r === rows) && (c === cols)) {
                                return mat;
                            } else {
                                var resultat = Matrix.zeros(rows, cols);
                                resultat = resultat.setSubMatrix(mat, 0, 0);
                                return resultat;
                            }
                        }
813301
public static DMatrix3x3 convert(DMatrixRMaj input , DMatrix3x3 output ) {
        if( output == null)
            output = new DMatrix3x3();

        if( input.getNumRows() != output.getNumRows() )
            throw new IllegalArgumentException("Number of rows do not match");
        if( input.getNumCols() != output.getNumCols() )
            throw new IllegalArgumentException("Number of columns do not match");

        output.a11 = input.data[0];
        output.a12 = input.data[1];
        output.a13 = input.data[2];
        output.a21 = input.data[3];
        output.a22 = input.data[4];
        output.a23 = input.data[5];
        output.a31 = input.data[6];
        output.a32 = input.data[7];
        output.a33 = input.data[8];

        return output;
    }
905914
def convert_tokens_into_matrix(self, token_list):
        '''
        
        '''
        return np.array(self.vectorize(token_list)).astype(np.float32)
1150485
def adapt(self, d, x):
        
        # create input matrix and target vector
        self.x_mem[:,1:] = self.x_mem[:,:-1]
        self.x_mem[:,0] = x
        self.d_mem[1:] = self.d_mem[:-1]
        self.d_mem[0] = d
        # estimate output and error
        self.y_mem = np.dot(self.x_mem.T, self.w)
        self.e_mem = self.d_mem - self.y_mem
        # update
        dw_part1 = np.dot(self.x_mem.T, self.x_mem) + self.ide_eps
        dw_part2 = np.linalg.solve(dw_part1, self.ide)
        dw = np.dot(self.x_mem, np.dot(dw_part2, self.e_mem))
        self.w += self.mu * dw