Base Operators¶
linop
sub-module¶
BaseLinearOperator
¶
Bases: object
Base class defining the common interface shared by all linear operators.
A linear operator is a linear mapping x -> A(x) such that the size of the
input vector x is nargin
and the size of the output is nargout
. It can
be visualized as a matrix of shape (nargout
, nargin
). Its type is any
valid Numpy dtype
. By default, it has dtype
numpy.float
but this can
be changed to, e.g., numpy.complex
via the dtype
keyword argument and
attribute.
A logger may be attached to the linear operator via the logger
keyword
argument.
Source code in brahmap/base/linop.py
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 78 79 80 81 82 83 84 85 86 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 132 133 134 |
|
dtype
property
writable
¶
The data type of the operator.
nMatvec
property
¶
The number of products with vectors computed so far.
nargin
property
¶
The size of an input vector.
nargout
property
¶
The size of an output vector.
shape
property
¶
The shape of the operator.
symmetric
property
¶
Indicate whether the operator is symmetric or not.
dot(x)
¶
DiagonalOperator
¶
Bases: LinearOperator
Class representing a diagonal operator.
A diagonal linear operator defined by its diagonal diag
(a Numpy array.)
The type must be specified in the diag
argument, e.g.,
np.ones(5, dtype=np.complex)
or np.ones(5).astype(np.complex)
.
Source code in brahmap/base/linop.py
IdentityOperator
¶
Bases: LinearOperator
Class representing the identity operator of size nargin
.
Source code in brahmap/base/linop.py
InverseLO
¶
Bases: LinearOperator
Construct the inverse operator of a matrix :math:A
, as a linear operator.
Parameters
A
: {linear operator} the linear operator of the linear system to invert;method
: {function } the method to computeA^-1
(see below);P
: {linear operator } (optional) the preconditioner for the computation of the inverse operator.
Source code in brahmap/base/linop.py
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 |
|
converged
property
¶
provides convergence information:
- 0 : successful exit;
-
0 : convergence to tolerance not achieved, number of iterations;
- <0 : illegal input or breakdown.
method
property
¶
The method to compute the inverse of A. \
It can be any :mod:scipy.sparse.linalg
solver, namely :func:scipy.sparse.linalg.cg
,
:func:scipy.sparse.linalg.bicg
, etc.
preconditioner
property
¶
Preconditioner for the solver.
isconverged(info)
¶
It returns a Boolean value depending on the exit status of the solver.
Parameters
info
: {int} output of the solver method (usually :func:scipy.sparse.cg
).
Source code in brahmap/base/linop.py
mult(x)
¶
It returns :math:y=A^{-1}x
by solving the linear system :math:Ay=x
with a certain :mod:scipy
routine (e.g. :func:scipy.sparse.linalg.cg
)
defined above as method
.
Source code in brahmap/base/linop.py
LinearOperator
¶
Bases: BaseLinearOperator
Generic linear operator class.
A linear operator constructed from a matvec
and (possibly) a
rmatvec
function. If symmetric
is True
, rmatvec
is
ignored. All other keyword arguments are passed directly to the superclass.
Source code in brahmap/base/linop.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 |
|
H
property
¶
The adjoint operator.
T
property
¶
The transpose operator.
.. note:: this is an alias to the adjoint operator
__mul_linop(op)
¶
Product between two linear operators.
Source code in brahmap/base/linop.py
__mul_scalar(x)
¶
Product between a linear operator and a scalar.
Source code in brahmap/base/linop.py
__mul_vector(x)
¶
Product between a linear operator and a vector.
matvec(x)
¶
Matrix-vector multiplication.
The matvec property encapsulates the matvec routine specified at construct time, to ensure the consistency of the input and output arrays with the operator's shape.
Source code in brahmap/base/linop.py
MatrixLinearOperator
¶
Bases: LinearOperator
Class representing a matrix operator.
A linear operator wrapping the multiplication with a matrix and its
transpose (real) or conjugate transpose (complex). The operator's dtype
is the same as the specified matrix
argument.
.. versionadded:: 0.3
Source code in brahmap/base/linop.py
ZeroOperator
¶
Bases: LinearOperator
Class representing the zero operator of shape nargout
-by-nargin
.
Source code in brahmap/base/linop.py
ReducedLinearOperator(op, row_indices, col_indices)
¶
Implement reduction of a linear operator (non symmetrical).
Reduce a linear operator by limiting its input to col_indices
and its
output to row_indices
.
Source code in brahmap/base/linop.py
SymmetricallyReducedLinearOperator(op, indices)
¶
Implement reduction of a linear operator (symmetrical).
Reduce a linear operator symmetrically by reducing boths its input and
output to indices
.
Source code in brahmap/base/linop.py
aslinearoperator(A)
¶
Return A as a LinearOperator.
'A' may be any of the following types: - linop.LinearOperator - scipy.LinearOperator - ndarray - matrix - sparse matrix (e.g. csr_matrix, lil_matrix, etc.) - any object with .shape and .matvec attributes
See the :class:LinearOperator
documentation for additonal information.
.. versionadded:: 0.4
Source code in brahmap/base/linop.py
635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 |
|
blkop
sub-module¶
BlockDiagonalPreconditioner
¶
Bases: BlockDiagonalLinearOperator
An alias for BlockDiagonalLinearOperator
.
Holds an additional solve
method equivalent to __mul__
.
Source code in brahmap/base/blkop.py
BlockHorizontalLinearOperator
¶
Bases: BlockLinearOperator
A block horizontal linear operator.
Each block must be a linear operator.
The blocks must be specified as one list, e.g., [A, B, C]
.
Source code in brahmap/base/blkop.py
BlockLinearOperator
¶
Bases: LinearOperator
A linear operator defined by blocks. Each block must be a linear operator.
blocks
should be a list of lists describing the blocks row-wise.
If there is only one block row, it should be specified as
[[b1, b2, ..., bn]]
, not as [b1, b2, ..., bn]
.
If the overall linear operator is symmetric, only its upper triangle
need be specified, e.g., [[A,B,C], [D,E], [F]]
, and the blocks on the
diagonal must be square and symmetric.
Source code in brahmap/base/blkop.py
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 78 79 80 81 82 83 84 85 86 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 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
|
blocks
property
¶
The list of blocks defining the block operator.
BlockPreconditioner
¶
Bases: BlockLinearOperator
An alias for BlockLinearOperator
.
Holds an additional solve
method equivalent to __mul__
.
Source code in brahmap/base/blkop.py
BlockVerticalLinearOperator
¶
Bases: BlockLinearOperator
A block vertical linear operator.
Each block must be a linear operator.
The blocks must be specified as one list, e.g., [A, B, C]
.