Concatenate Matrix objects.  Tries either axis.

    Parameters
    ----------
    mats: list
        list of Matrix objects

    Returns
    -------
    Matrix : Matrix
320245
def concat(mats):
    
    for mat in mats:
        if mat.isdiagonal:
            raise NotImplementedError("concat not supported for diagonal mats")

    row_match = True
    col_match = True
    for mat in mats[1:]:
        if sorted(mats[0].row_names) != sorted(mat.row_names):
            row_match = False
        if sorted(mats[0].col_names) != sorted(mat.col_names):
            col_match = False
    if not row_match and not col_match:
        raise Exception("mat_handler.concat(): all Matrix objects"+\
                        "must share either rows or cols")

    if row_match and col_match:
        raise Exception("mat_handler.concat(): all Matrix objects"+\
                        "share both rows and cols")

    if row_match:
        row_names = copy.deepcopy(mats[0].row_names)
        col_names = []
        for mat in mats:
            col_names.extend(copy.deepcopy(mat.col_names))
        x = mats[0].newx.copy()
        for mat in mats[1:]:
            mat.align(mats[0].row_names, axis=0)
            other_x = mat.newx
            x = np.append(x, other_x, axis=1)

    else:
        col_names = copy.deepcopy(mats[0].col_names)
        row_names = []
        for mat in mats:
            row_names.extend(copy.deepcopy(mat.row_names))
        x = mats[0].newx.copy()
        for mat in mats[1:]:
            mat.align(mats[0].col_names, axis=1)
            other_x = mat.newx
            x = np.append(x, other_x, axis=0)
    return Matrix(x=x, row_names=row_names, col_names=col_names)
218640
def _concatenate_shape(input_shape, axis=-1):  # pylint: disable=invalid-name
  """"""
  ax = axis % len(input_shape[0])
  concat_size = sum(shape[ax] for shape in input_shape)
  out_shape = input_shape[0][:ax] + (concat_size,) + input_shape[0][ax+1:]
  return out_shape
1010306
def transpose_axes(image, axes, asaxes=None):
    
    for ax in axes:
        if ax not in asaxes:
            raise ValueError('unknown axis %s' % ax)
    # add missing axes to image
    if asaxes is None:
        asaxes = 'CTZYX'
    shape = image.shape
    for ax in reversed(asaxes):
        if ax not in axes:
            axes = ax + axes
            shape = (1,) + shape
    image = image.reshape(shape)
    # transpose axes
    image = image.transpose([axes.index(ax) for ax in asaxes])
    return image
283831
def rotation_matrix(axis, theta):
    
    axis = np.asarray(axis)
    axis = axis / np.linalg.norm(axis)
    a = np.cos(theta / 2)
    b, c, d = -axis * np.sin(theta / 2)
    aa, bb, cc, dd = a * a, b * b, c * c, d * d
    bc, ad, ac, ab, bd, cd = b * c, a * d, a * c, a * b, b * d, c * d
    return np.array([
        [aa + bb - cc - dd, 2 * (bc + ad), 2 * (bd - ac)],
        [2 * (bc - ad), aa + cc - bb - dd, 2 * (cd + ab)],
        [2 * (bd + ac), 2 * (cd - ab), aa + dd - bb - cc],
    ])
623725
def matrix(self, _):
        """"""
        x, y, z = self.coord
        return np.array([
            [1., 0., 0., x],
            [0., 1., 0., y],
            [0., 0., 1., z],
            [0., 0., 0., 1.]
        ])
177497
def _lincomb(self, a, x1, b, x2, out):
        """"""
        self.tspace._lincomb(a, x1.tensor, b, x2.tensor, out.tensor)
669206
function matmul(A, B) {
    var shapeA = A.shape;
    var shapeB = B.shape;
    if (shapeA.length > 2 || shapeB.length > 2) {
        throw new Error('Array shape is > 2D, not suitable for ' +
            'matrix multiplication');
    }
    // Treat a flat n-item array as 1xn matrix
    if (shapeA.length === 1) {
        shapeA = [1, shapeA[0]];
    }
    if (shapeB.length === 1) {
        shapeB = [1, shapeB[0]];
    }
    if (shapeA[1] !== shapeB[0]) {
        throw new Error('Matrix shapes ' + shapeA.join('x') + ' and ' +
            shapeB.join('x') + ' not compatible for multiplication');
    }
    // If one of the matrices is flat n-item array clone them into 1xn NDArray
    var mA, mB;
    if (A.shape.length === 1) {
        mA = A.clone();
        mA.reshape([1, A.shape[0]]);
    }
    else {
        mA = A;
    }
    if (B.shape.length === 1) {
        mB = B.clone();
        mB.reshape([1, B.shape[0]]);
    }
    else {
        mB = B;
    }
    var result = new common_1.NDArray({ shape: [mA.shape[0], mB.shape[1]] });
    for (var i = 0; i < mA.shape[0]; i++) {
        for (var j = 0; j < mB.shape[1]; j++) {
            var value = 0.0;
            for (var k = 0; k < mA.shape[1]; k++) {
                value += A.get(i, k) * B.get(k, j); // TODO:Complex
            }
            result.set(i, j, value);
        }
    }
    return result;
}
179836
public Vector4d mul(Matrix4fc mat, Vector4d dest) {
        if ((mat.properties() & Matrix4fc.PROPERTY_AFFINE) != 0)
            return mulAffine(mat, dest);
        return mulGeneric(mat, dest);
    }
50673
def schur_complement(mat, row, col):
    
    a = mat[:row, :col]
    b = mat[:row, col:]
    c = mat[row:, :col]
    d = mat[row:, col:]
    return a - b.dot(d.I).dot(c)
116641
public Vector2f mulDirection(Matrix3x2fc mat, Vector2f dest) {
        dest.set(mat.m00() * x + mat.m10() * y,
                 mat.m01() * x + mat.m11() * y);
        return dest;
    }
358650
def swapaxes(self, axis1, axis2, copy=True):
        
        i = self._get_axis_number(axis1)
        j = self._get_axis_number(axis2)

        if i == j:
            if copy:
                return self.copy()
            return self

        mapping = {i: j, j: i}

        new_axes = (self._get_axis(mapping.get(k, k))
                    for k in range(self._AXIS_LEN))
        new_values = self.values.swapaxes(i, j)
        if copy:
            new_values = new_values.copy()

        return self._constructor(new_values, *new_axes).__finalize__(self)
325179
function makeMatrix(n, m, x) {
  var matrix = [];
  for (var i = 0; i < n; i++) {
    matrix[i] = new Array(m);
    for (var j = 0; j < m; j++) {
      matrix[i][j] = x;
    }
  }

  return matrix;
}
664385
def bbox(self):
        
        mn = amin(self.coordinates, axis=0)
        mx = amax(self.coordinates, axis=0)
        return concatenate((mn, mx))
1116864
function ( sx, sy, sz ) {
            var mtx3d = new $B.geom.Matrix3D( sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0 );
            return this.concat( mtx3d );
        }
460829
def rotateCoords(coords, R):
    
    newlist = list()
    for pp in coords:
        rpp = matrixTimesVector(R, pp)
        newlist.append(rpp)
    return newlist
1089880
def axis_rotation_matrix(axis, theta):
    """"""
    [x, y, z] = axis
    c = np.cos(theta)
    s = np.sin(theta)
    return np.array([
        [x**2 + (1 - x**2) * c, x * y * (1 - c) - z * s, x * z * (1 - c) + y * s],
        [x * y * (1 - c) + z * s, y ** 2 + (1 - y**2) * c, y * z * (1 - c) - x * s],
        [x * z * (1 - c) - y * s, y * z * (1 - c) + x * s, z**2 + (1 - z**2) * c]
    ])
211908
def concat(self, one, two):
        """"""
        if not len(one) == len(two) == 6:
            raise ValueError("bad sequ. length")
        self.a, self.b, self.c, self.d, self.e, self.f = TOOLS._concat_matrix(one, two)
        return self