File: t_ARMACoefficients_std.py

package info (click to toggle)
openturns 1.24-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 66,204 kB
  • sloc: cpp: 256,662; python: 63,381; ansic: 4,414; javascript: 406; sh: 180; xml: 164; yacc: 123; makefile: 98; lex: 55
file content (77 lines) | stat: -rwxr-xr-x 1,926 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#! /usr/bin/env python

import openturns as ot

ot.TESTPREAMBLE()


#  Constructor with size
dimension = 2
squareMatrix1 = ot.SquareMatrix(dimension)

squareMatrix1[0, 0] = 1.0
squareMatrix1[1, 0] = 2.0
squareMatrix1[0, 1] = 3.0
squareMatrix1[1, 1] = 4.0

# Second matrix to add to the ARMACoefficients
s = 3.0
squareMatrix2 = squareMatrix1 * s

# Second matrix to add to the ARMACoefficients
t = 1.5
squareMatrix3 = squareMatrix1 / t

# size : Number of matrix
size = 3

# ARMACoefficients with default constructor
coefficients0 = ot.ARMACoefficients()
print("Using default constructor ")
print("coefficients0 = ", coefficients0)

# ARMACoefficients with size / dimension constructor
coefficients1 = ot.ARMACoefficients(size, dimension)
coefficients1[0] = squareMatrix1
coefficients1[1] = squareMatrix2
coefficients1[2] = squareMatrix3

print("Using constructor based on size / dimension ")
print("coefficients1 = ", repr(coefficients1))

# constructors with collection of matrix
myCollection = ot.SquareMatrixCollection()
myCollection.add(squareMatrix1)
myCollection.add(squareMatrix2)
myCollection.add(squareMatrix3)

print("SquareMatrix collection = ", repr(myCollection))
coefficients2 = ot.ARMACoefficients(myCollection)

# print  of the new collection
print("Using constructor based on a collection ")
print("coefficients2 = ", repr(coefficients2))

# 1D case
point = ot.Point(dimension * dimension, 0.0)
point[0] = 1.0
point[1] = 2.0
point[2] = 3.0
point[3] = 4.0

# ARMACoefficients Point constructor
coefficients3 = ot.ARMACoefficients(point)

# print  of the new collection
print("Using Point constructor ")
print("coefficients3 = ", repr(coefficients3))

# ARMACoefficients with polynomial constructor
point *= 2.0
poly = ot.UniVariatePolynomial(point)

coefficients4 = ot.ARMACoefficients(poly)

# print  of the new collection
print("Using polynomial constructor ")
print("coefficients4 = ", repr(coefficients4))