Return the A_hat matrix of A given the skew matrix S
328598
def calc_A_hat(A, S):
    ''''''
    return np.dot(S, np.dot(A, np.transpose(S)))
921846
def simxGetJointMatrix(clientID, jointHandle, operationMode):
    '''
    
    '''
    matrix = (ct.c_float*12)()
    ret = c_GetJointMatrix(clientID, jointHandle, matrix, operationMode)
    arr = []
    for i in range(12):
        arr.append(matrix[i])
    return ret, arr
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]
    ])
951934
def s2a(s):
    
    a = np.zeros((3, 3,), 'f')  # make the a matrix
    for i in range(3):
        a[i][i] = s[i]
    a[0][1], a[1][0] = s[3], s[3]
    a[1][2], a[2][1] = s[4], s[4]
    a[0][2], a[2][0] = s[5], s[5]
    return a
557344
def _get_zoom_mat(sw:float, sh:float, c:float, r:float)->AffineMatrix:
    ""
    return [[sw, 0,  c],
            [0, sh,  r],
            [0,  0, 1.]]
1352597
def symbolic_rotation_matrix(phi, theta, symbolic_psi):
    """"""
    return sympy.Matrix(Rz_matrix(phi)) * sympy.Matrix(Rx_matrix(theta)) * symbolic_Rz_matrix(symbolic_psi)
558206
def symbolic_axis_rotation_matrix(axis, symbolic_theta):
    """"""
    [x, y, z] = axis
    c = sympy.cos(symbolic_theta)
    s = sympy.sin(symbolic_theta)
    return sympy.Matrix([
        [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]
    ])
1000743
def imag(self):
        """"""
        return matrix(self.tt.imag(), n=self.n, m=self.m)
694892
def Rz_matrix(theta):
    """"""
    return np.array([
        [np.cos(theta), -np.sin(theta), 0],
        [np.sin(theta), np.cos(theta), 0],
        [0, 0, 1]
    ])
1361461
def eighCovarianceMatrix(cfile):
    
    # precompute eigenvalue decomposition
    K = np.loadtxt(cfile+'.cov')
    K+= 1e-4*sp.eye(K.shape[0])
    S,U = la.eigh(K); S=S[::-1]; U=U[:,::-1]
    np.savetxt(cfile+'.cov.eval',S,fmt='%.6f')
    np.savetxt(cfile+'.cov.evec',U,fmt='%.6f')
743454
def getProjectionMatrix(self, eEye, fNearZ, fFarZ):
        """"""

        fn = self.function_table.getProjectionMatrix
        result = fn(eEye, fNearZ, fFarZ)
        return result
377988
def _q_matrix(self):
        
        return np.array([
            [self.q[0], -self.q[1], -self.q[2], -self.q[3]],
            [self.q[1],  self.q[0], -self.q[3],  self.q[2]],
            [self.q[2],  self.q[3],  self.q[0], -self.q[1]],
            [self.q[3], -self.q[2],  self.q[1],  self.q[0]]])
479286
function getShape(x,y,modules,options){

  //Get the surrounding modules matrix
  var mod_matrix = {};
  mod_matrix.topLeft = (x!=0 && y!=0 && modules[x-1][y-1]);
  mod_matrix.top = (y!=0 && modules[x][y-1]);
  mod_matrix.topRight = (x!=modules.length-1 && y!=0 && modules[x+1][y-1]);
  mod_matrix.left = (x!=0 && modules[x-1][y]);
  mod_matrix.right = (x!=modules.length-1 && modules[x+1][y]);
  mod_matrix.bottomLeft = (x!=0 && y!=modules.length-1 && modules[x-1][y+1]);
  mod_matrix.bottom = (y!=modules.length-1 && modules[x][y+1]);
  mod_matrix.bottomRight = (x!=modules.length-1 && y!=modules.length-1 && modules[x+1][y+1]);

  var surroundingCount = 0;
  if(mod_matrix.top){surroundingCount++;}
  if(mod_matrix.left){surroundingCount++;}
  if(mod_matrix.right){surroundingCount++;}
  if(mod_matrix.bottom){surroundingCount++;}

  //Find out box shape from surroundingCount and the orientation of those surrounding modules
  switch(surroundingCount){
    case 0:
      return getShapeZero(x,y,options,modules);
    case 1:
      return getShapeOne(x,y,options,modules,mod_matrix);
    case 2:
      return getShapeTwo(x,y,options,modules,mod_matrix);
    case 3:
      return getShapeThree(x,y,options,modules,mod_matrix);
    case 4:
      return getShapeFour(x,y,options,modules,mod_matrix);
    default:
      return getShapeZero(x,y,options,modules);
  }
      //This function checks that arrays a1 and a2 are the same:
      /*  a1.length==a2.length && a1.every(function(v,i) { return v === a2[i]}) */

}
343787
def inverse(self):
        
        invr = np.linalg.inv(self.affine_matrix)
        return SymmOp(invr)
562595
def asML(self):
        
        return newlinalg.SparseMatrix(self.numRows, self.numCols, self.colPtrs, self.rowIndices,
                                      self.values, self.isTransposed)
389404
function skew(ax, ay) {
    return {
        a: 1, c: tan(ax), e: 0,
        b: tan(ay), d: 1, f: 0
    };
}
185487
def get_matrix(self):
        """"""
        if self.parent:
            return self.get_local_matrix() * (self._prev_parent_matrix or self.parent.get_matrix())
        else:
            return self.get_local_matrix()