本文整理汇总了Python中sympy.matrices.Matrix.transpose方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.transpose方法的具体用法?Python Matrix.transpose怎么用?Python Matrix.transpose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.matrices.Matrix
的用法示例。
在下文中一共展示了Matrix.transpose方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _eval_transpose
# 需要导入模块: from sympy.matrices import Matrix [as 别名]
# 或者: from sympy.matrices.Matrix import transpose [as 别名]
def _eval_transpose(self):
# Flip all the individual matrices
matrices = [Transpose(matrix) for matrix in self.blocks]
# Make a copy
M = Matrix(self.blockshape[0], self.blockshape[1], matrices)
# Transpose the block structure
M = M.transpose()
return BlockMatrix(M)
示例2: evalMat
# 需要导入模块: from sympy.matrices import Matrix [as 别名]
# 或者: from sympy.matrices.Matrix import transpose [as 别名]
def evalMat( Mlist, blist ):
M = Matrix(Mlist)
b = Matrix(blist)
c = M.LUsolve( b )
print
print " ================= Case: ",b.transpose()
print
print c
return c
示例3: test_1xN_vecs
# 需要导入模块: from sympy.matrices import Matrix [as 别名]
# 或者: from sympy.matrices.Matrix import transpose [as 别名]
def test_1xN_vecs():
gl = glsl_code
for i in range(1,10):
A = Matrix(range(i))
assert gl(A.transpose()) == gl(A)
assert gl(A,mat_transpose=True) == gl(A)
if i > 1:
if i <= 4:
assert gl(A) == 'vec%s(%s)' % (i,', '.join(str(s) for s in range(i)))
else:
assert gl(A) == 'float[%s](%s)' % (i,', '.join(str(s) for s in range(i)))
示例4: mc_compute_stationary_sympy
# 需要导入模块: from sympy.matrices import Matrix [as 别名]
# 或者: from sympy.matrices.Matrix import transpose [as 别名]
def mc_compute_stationary_sympy(P, tol=1e-10):
"""
Computes the stationary distribution(s) of Markov matrix P.
Parameters
----------
P : array_like(float, ndim=2)
A discrete Markov transition matrix
tol : scalar(float) optional
Tolerance level
Find eigenvectors for eigenvalues > 1 - tol
Returns
-------
vals : list of sympy.core.numbers.Float
A list of eigenvalues of P > 1 - tol
ndarray_vects : list of numpy.arrays of sympy.core.numbers.Float
A list of the corresponding eigenvectors of P
"""
P = Matrix(P) # type(P): sympy.matrices.dense.MutableDenseMatrix
outputs = P.transpose().eigenvects() # TODO: Raise exception when empty
vals = []
vecs = []
# output = (eigenvalue, algebraic multiplicity, [eigenvectors])
for output in outputs:
if output[0] > 1 - tol:
vals.append(output[0])
vecs.extend(output[2])
# type(vec): sympy.matrices.dense.MutableDenseMatrix
vecs_flattened = \
np.array([flatten(vec) for vec in vecs])
return vals, [vec/sum(vec) for vec in vecs_flattened]
示例5: test_Matrices_1x7
# 需要导入模块: from sympy.matrices import Matrix [as 别名]
# 或者: from sympy.matrices.Matrix import transpose [as 别名]
def test_Matrices_1x7():
gl = glsl_code
A = Matrix([1,2,3,4,5,6,7])
assert gl(A) == 'float[7](1, 2, 3, 4, 5, 6, 7)'
assert gl(A.transpose()) == 'float[7](1, 2, 3, 4, 5, 6, 7)'
示例6: symbols
# 需要导入模块: from sympy.matrices import Matrix [as 别名]
# 或者: from sympy.matrices.Matrix import transpose [as 别名]
wg = symbols('wg', real=True, positive=True)
omegag_2 = g*g*2*2*pi*pi*k[0]*k[0]*s[1]*s[1]+g*g*2*2*pi*pi*k[1]*k[1]*s[0]*s[0]+f*f*s[0]*s[0]*s[1]*s[1]
eq_subs[omegag_2] = wg*wg
eq_subs[-omegag_2] = -wg*wg
inv_eq_subs[wg] = sqrt(omegag_2)
# replace k0*k0 + k1*k1 by 'K2' symbol
K2 = symbols('K2', real=True, positive=True)
asdf = pi*pi*k[0]*k[0]+pi*pi*k[1]*k[1]
eq_subs[asdf] = K2
inv_eq_subs[K2] = asdf
# Solution expressed with variables in spectral space
U_spec = U_spec.transpose()
#
# Solution given in Cartesian space, but expressed in spectral space
# Remove 2*pi for "2pi-sized" domain
#
U_fromSpec = exp(I*2*pi*(k[0]*x[0]/s[0]+k[1]*x[1]/s[1])) * U_spec
print
print
print("L(U):")
M = getL(U_fromSpec)
pprint(M)
# Remove spectral basis components (This should be possible in general)
示例7: Symbol
# 需要导入模块: from sympy.matrices import Matrix [as 别名]
# 或者: from sympy.matrices.Matrix import transpose [as 别名]
"Coupling lattice Boltzmann model for simulation of thermal flows on stanard lattices" \
"by Q. Li, K. H. Luo, Y.L.He., Y.J. Gao, W.Q Tao, 2012"
phi_x = Symbol("phi_x")
phi_y = Symbol("phi_y")
C_D2Q9 = Matrix([-1 / 9 * phi_x,
-phi_x / 36 + phi_y / 4,
-phi_x / 36 - phi_y / 4, # suprisingly the article applies asymmetric correction in x and y direction
-phi_x / 36 + phi_y / 4,
-phi_x / 36 - phi_y / 4,
phi_x / 18,
phi_x / 18,
phi_x / 18,
phi_x / 18, ])
print_as_vector(C_D2Q9.transpose() * Mraw_D2Q9, print_symbol="pop_in_str")
#
# print('\n//population_eq -> cm_eq - from continous definition: \n'
# 'k_mn = integrate(fun, (x, -oo, oo), (y, -oo, oo)) \n'
# 'where fun = fM(rho,u,x,y) *(x-ux)^m (y-uy)^n')
# cm_eq = get_mom_vector_from_continuous_def(get_continuous_Maxwellian_DF, continuous_transformation=get_continuous_cm)
# # cm_eq = get_mom_vector_from_continuous_def(get_continuous_hydro_DF, continuous_transformation=get_continuous_cm)
# print_as_vector(cm_eq, 'cm_eq')
# import re
# re.findall(r'\d+', 'hello 42 I\'m a 32 string 30')
# ['42', '32', '30']
# # This would also match 42 from bla42bla. If you only want numbers delimited by word boundaries (space, period, comma), you can use \b :
#