linalg
linalg_ddot(n, x, incx, y, incy)
¶
Perform the dot product of two vectors x and y.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n |
int
|
The number of elements in the vectors. |
required |
x |
ndarray
|
The vector x. |
required |
incx |
int
|
The increment for the elements of x. |
required |
y |
ndarray
|
The vector y. |
required |
incy |
int
|
The increment for the elements of y. |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The dot product of x and y. |
Examples:
>>> n = 3
>>> x = np.array([1, 2, 3], dtype=float)
>>> incx = 1
>>> y = np.array([4, 5, 6], dtype=float)
>>> incy = 1
>>> result = linalg_ddot(n, x, incx, y, incy)
>>> print(result)
32.0
Source code in spotpython/gp/linalg.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
linalg_dposv(n, Mutil, Mi)
¶
Solve the linear equations A * x = B for x, where A is a symmetric positive definite matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n |
int
|
The order of the matrix Mutil. |
required |
Mutil |
ndarray
|
The matrix A. |
required |
Mi |
ndarray
|
The matrix B. |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple |
tuple
|
The updated matrix Mi and an info flag. - Mi (ndarray): The solution matrix x. - Info flag (0 if successful, non-zero if an error occurred). |
Notes
Analog of dposv in clapack and lapack where Mutil is with colmajor and uppertri or rowmajor and lowertri.
Examples:
>>> import numpy as np
>>> from spotpython.gp.gp_sep import linalg_dposv
>>> n = 3
>>> Mutil = np.array([[4, 12, -16], [12, 37, -43], [-16, -43, 98]], dtype=float)
>>> Mi = np.eye(n)
>>> info = linalg_dposv(n, Mutil, Mi)
>>> print("Info:", info)
>>> print("Mi:", Mi)
Info: 0
Mi: [[ 49.36111111 -13.55555556 2.11111111]
[-13.55555556 3.77777778 -0.55555556]
[ 2.11111111 -0.55555556 0.11111111]]
Source code in spotpython/gp/linalg.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
linalg_dsymv(n, alpha, A, lda, x, incx, beta, y, incy)
¶
Perform the symmetric matrix-vector operation y := alphaAx + beta*y.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n |
int
|
The order of the matrix A. |
required |
alpha |
float
|
The scalar alpha. |
required |
A |
ndarray
|
The n x n symmetric matrix. |
required |
lda |
int
|
The leading dimension of A. |
required |
x |
ndarray
|
The vector x. |
required |
incx |
int
|
The increment for the elements of x. |
required |
beta |
float
|
The scalar beta. |
required |
y |
ndarray
|
The vector y. |
required |
incy |
int
|
The increment for the elements of y. |
required |
Returns:
Name | Type | Description |
---|---|---|
ndarray |
ndarray
|
The updated vector y. |
Examples:
>>> n = 3
>>> alpha = 1.0
>>> A = np.array([[1, 2, 3], [2, 4, 5], [3, 5, 6]], dtype=float)
>>> lda = 3
>>> x = np.array([1, 1, 1], dtype=float)
>>> incx = 1
>>> beta = 0.0
>>> y = np.zeros(3, dtype=float)
>>> incy = 1
>>> linalg_dsymv(n, alpha, A, lda, x, incx, beta, y, incy)
>>> print(y)
[ 6. 11. 14.]
Source code in spotpython/gp/linalg.py
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 |
|