m0 = ot.CorrelationMatrix(2, t0) print("tuple", t0, "=> CorrelationMatrix", m0) m0 = ot.CovarianceMatrix(2, t0) print("tuple", t0, "=> CovarianceMatrix", m0) t0c = (1. + 3.j, 2. - 5.j, 3. + 7.j, 4. - 9.j) m0 = ot.ComplexMatrix(2, 2, t0) print("tuple", t0, "=> ComplexMatrix", m0) m0 = ot.ComplexMatrix(2, 2, t0c) print("tuple", t0c, "=> ComplexMatrix", m0) m0 = ot.SquareComplexMatrix(2, t0) print("tuple", t0, "=> SquareComplexMatrix", m0) m0 = ot.SquareComplexMatrix(2, t0c) print("tuple", t0c, "=> SquareComplexMatrix", m0) # Check Matrix list constructor l0 = [1., 2., 3., 4.] m0 = ot.Matrix(2, 2, l0) print("list", l0, "=> Matrix", m0) m0 = ot.SquareMatrix(2, l0) print("list", l0, "=> SquareMatrix", m0) m0 = ot.SymmetricMatrix(2, l0) print("list", l0, "=> SymmetricMatrix", m0)
import openturns as ot ref_values = [[1.0, 0.0], [0.0, 0.5]] mats = [ot.Matrix(ref_values), ot.SquareMatrix(ref_values), ot.TriangularMatrix(ref_values), ot.SymmetricMatrix(ref_values), ot.CovarianceMatrix(ref_values), ot.CorrelationMatrix(ref_values)] mats.extend([ ot.ComplexMatrix(ref_values), ot.HermitianMatrix(ref_values), ot.TriangularComplexMatrix(ref_values), ot.SquareComplexMatrix(ref_values)]) for a in mats: # try conversion ref = ot.Matrix([[1.0, 0.0], [0.0, 0.5]]) iname = a.__class__.__name__ print('a=', a) # try scalar mul try: s = 5. ats = a * s print('a*s=', ats) sta = s * a print('s*a=', sta)
#! /usr/bin/env python from __future__ import print_function import openturns as ot from math import * # DEFAULT CONSTRUCTOR AND STRING CONVERTER print('test : default constructor and string converter') # Default constructor squareComplexMatrix0 = ot.SquareComplexMatrix() # String converter print('squareComplexMatrix0 = ', repr(squareComplexMatrix0)) # CONSTRUCTOR WITH SIZE, OPERATOR() AND STRING CONVERTER print('test : constructor with size, operator() and string converter') # Constructor with size squareComplexMatrix1 = ot.SquareComplexMatrix(2) # Check operator() methods squareComplexMatrix1[0, 0] = 1. + 1j squareComplexMatrix1[0, 1] = 3. + 1j squareComplexMatrix1[1, 0] = 1.0j squareComplexMatrix1[1, 1] = 5. + 1.j # String converter print('squareComplexMatrix1 = ', repr(squareComplexMatrix1)) # COPY CONSTRUCTOR AND STRING CONVERTER