Convert ``x`` to an array.

        Here the indices are changed such that the "outer" indices come last
        in order to have the access order as `numpy.linalg.svd` needs it.

        This is the inverse of `_asvector`.
762216
def _asarray(self, vec):
        
        shape = self.domain[0, 0].shape + self.pshape
        arr = np.empty(shape, dtype=self.domain.dtype)
        for i, xi in enumerate(vec):
            for j, xij in enumerate(xi):
                arr[..., i, j] = xij.asarray()

        return arr
1153679
def cnst_A(self, X):
        
        """

        return np.concatenate(
            [sl.Gax(X, ax)[..., np.newaxis] for ax in self.axes] +
            [X[..., np.newaxis],], axis=X.ndim)
1139741
def prior_to_xarray(self):
        """"""
        return dict_to_dataset(
            {k: np.expand_dims(v, 0) for k, v in self.prior.items()},
            library=self.pymc3,
            coords=self.coords,
            dims=self.dims,
        )
643765
def get_array_indices(self):
        """"""

        for token in self.tokens:
            if isinstance(token, SquareBrackets):
                # Use [1:-1] index to discard the square brackets
                yield token.tokens[1:-1]
1080960
def __set_svd(self):
        
        if self.isdiagonal:
            x = np.diag(self.x.flatten())
        else:
            # just a pointer to x
            x = self.x
        try:

            u, s, v = la.svd(x, full_matrices=True)
            v = v.transpose()
        except Exception as e:
            print("standard SVD failed: {0}".format(str(e)))
            try:
                v, s, u = la.svd(x.transpose(), full_matrices=True)
                u = u.transpose()
            except Exception as e:
                np.savetxt("failed_svd.dat",x,fmt="%15.6E")
                raise Exception("Matrix.__set_svd(): " +
                                "unable to compute SVD of self.x, " +
                                "saved matrix to 'failed_svd.dat' -- {0}".\
                                format(str(e)))

        col_names = ["left_sing_vec_" + str(i + 1) for i in range(u.shape[1])]
        self.__u = Matrix(x=u, row_names=self.row_names,
                          col_names=col_names, autoalign=False)

        sing_names = ["sing_val_" + str(i + 1) for i in range(s.shape[0])]
        self.__s = Matrix(x=np.atleast_2d(s).transpose(), row_names=sing_names,
                          col_names=sing_names, isdiagonal=True,
                          autoalign=False)

        col_names = ["right_sing_vec_" + str(i + 1) for i in range(v.shape[0])]
        self.__v = Matrix(v, row_names=self.col_names, col_names=col_names,
                          autoalign=False)
249539
def toarray(self):
        
        return asarray([value.toarray() for (key, value) in sorted(self.transformations.items())])
351431
def _to_array(self, alpha, normalization='4pi', csphase=1):
        
        if self.coeffs is None:
            coeffs = _np.copy(self._taper2coeffs(alpha))
        else:
            if alpha > self.nrot - 1:
                raise ValueError('alpha must be less than or equal to ' +
                                 'nrot - 1. alpha = {:d}, nrot = {:d}'
                                 .format(alpha, self.nrot))
            coeffs = _shtools.SHVectorToCilm(self.coeffs[:, alpha])

        if normalization == 'schmidt':
            for l in range(self.lmax + 1):
                coeffs[:, l, :l+1] *= _np.sqrt(2.0 * l + 1.0)
        elif normalization == 'ortho':
            coeffs *= _np.sqrt(4.0 * _np.pi)

        if csphase == -1:
            for m in range(self.lmax + 1):
                if m % 2 == 1:
                    coeffs[:, :, m] = - coeffs[:, :, m]

        return coeffs
275734
private static double[] toVector(Point3d src, Point3d dest) {
        return new double[]{dest.x - src.x, dest.y - src.y, dest.z - src.z};
    }
206597
function rank(A, tol) {
    var S = svd(A, false, false)[0];
    if (tol === undefined) {
        tol = common_1.EPSILON; // TODO : use numpy's formula
    }
    var rank = 0;
    for (var _i = 0, _a = S.toArray(); _i < _a.length; _i++) {
        var n = _a[_i];
        if (n > tol) {
            rank++;
        }
    }
    return rank;
}
1185716
def vars_to_array(self):
        

        logger.warn('This function is deprecated. You can inspect `self.np_vars` directly as NumPy arrays '
                    'without conversion.')
        if not self.vars:
            return None

        vars_matrix = matrix(self.vars, size=(self.vars[0].size[0],
                                              len(self.vars))).trans()

        self.vars_array = np.array(vars_matrix)

        return self.vars_array
708579
def translate_x(self, d):
        
        mat = numpy.array([
            [1, 0, 0, 0],
            [0, 1, 0, 0],
            [0, 0, 1, 0],
            [d, 0, 0, 1]
        ])
        self.vectors = self.vectors.dot(mat)
        return self
928914
def _svd(cls, matrix, num_concepts=5):
        
        u, s, v = svds(matrix, k=num_concepts)
        return u, s, v
1111563
private double[][] getAugmentedData(double[][] x) {
        double[][] ret = new double[x.length + p][p];
        double padding = c * Math.sqrt(lambda2);
        for (int i = 0; i < x.length; i++) {
            for (int j = 0; j < p; j++) {
                ret[i][j] = c * x[i][j];
            }
        }
        for (int i = x.length; i < ret.length; i++) {
            ret[i][i - x.length] = padding;
        }
        return ret;
    }
721554
def _as_array(arr, dtype=None):
    
    if arr is None:
        return None
    if isinstance(arr, np.ndarray) and dtype is None:
        return arr
    if isinstance(arr, integer_types + (float,)):
        arr = [arr]
    out = np.asarray(arr)
    if dtype is not None:
        if out.dtype != dtype:
            out = out.astype(dtype)
    if out.dtype not in _ACCEPTED_ARRAY_DTYPES:
        raise ValueError("'arr' seems to have an invalid dtype: "
                         "{0:s}".format(str(out.dtype)))
    return out
571723
def to_gsl
      numerics_as_arrays = numeric_vectors.map { |n| self[n].to_a }

      GSL::Matrix.alloc(*numerics_as_arrays.transpose)
    end
1282811
def invcdf(x):
    """"""
    x_flat = np.ravel(x)
    x_trans = np.array([flib.ppnd16(y, 1) for y in x_flat])
    return np.reshape(x_trans, np.shape(x))
1094467
def GetVectorAsNumpy(self, flags, off):
        
        offset = self.Vector(off)
        length = self.VectorLen(off) # TODO: length accounts for bytewidth, right?
        numpy_dtype = N.to_numpy_type(flags)
        return encode.GetVectorAsNumpy(numpy_dtype, self.Bytes, length, offset)