Пример #1
0
    def preMatrixMinus(self, a):
        b = si.sqrt(1 + a**2)
        matrix = si.zeros(2)

        matrix[0, 0] = 1 - b
        matrix[0, 1] = -a
        matrix[1, 0] = a
        matrix[1, 1] = 1 + b
        return matrix
Пример #2
0
def entrywise_product(matrix1, matrix2):
    """
    :type matrix1: se.Matrix
    :type matrix2: se.Matrix
    :return:
    """
    assert matrix1.shape == matrix2.shape
    result = se.zeros(*matrix1.shape)
    for i in range(matrix1.shape[0]):
        for j in range(matrix1.shape[1]):
            result[i, j] = matrix1[i, j] * matrix2[i, j]
    return result
Пример #3
0
def piecewise_matrix(*piecewise_vector):
    # TODO testme
    # FIXME support non 2d matrices?
    dimensions = piecewise_vector[0][0].shape
    for m, condition in piecewise_vector:
        assert m.shape == dimensions
    matrix = se.zeros(*dimensions)
    for x in range(dimensions[0]):
        for y in range(dimensions[1]):
            piecewise_entry = []
            for m, condition in piecewise_vector:
                piecewise_entry.append([m[x, y], condition])
            matrix[x, y] = se.Piecewise(*piecewise_entry)
    return matrix
Пример #4
0
import symengine

vars = symengine.symbols('x y')  # Define x and y variables
f = symengine.sympify(['y*x**2', '5*x + sin(y)']) # Define function
J = symengine.zeros(len(f), len(vars)) # Initiate Jacobian matrix

# Fill Jacobian Matrix with entries
for i, fi in enumerate(f):
    for j, s in enumerate(vars):
        J[i,j] = symengine.diff(fi, s)

print(J)

Пример #5
0
from symengine import I
from sympy.printing import ccode
from Numerical_CFS_Docker.configfunktion import configfunktion
from Numerical_CFS_Docker import get_data
import sympy as sy
import symengine as si
import numpy as np
from scipy import integrate
import random
import time
import os
import scipy.misc
import ctypes
import subprocess

sigma1 = si.zeros(2)
sigma1[1, 0] = 1
sigma1[0, 1] = 1
sigma2 = si.zeros(2)
sigma2[1, 0] = I
sigma2[0, 1] = -I
sigma3 = si.zeros(2)
sigma3[0, 0] = 1
sigma3[1, 1] = -1
ident = si.zeros(2)
ident[0, 0] = 1
ident[1, 1] = 1
r = si.symarray('r', 1)
t = si.symarray('t', 1)
'''
For more information on these Functions, look in to the master