### Install and Test LinearOperators.jl Package Source: https://github.com/juliasmoothoptimizers/linearoperators.jl/blob/main/docs/src/index.md Instructions for adding and testing the LinearOperators.jl package using the Julia package manager. This ensures the package is installed and its functionalities are verified. ```Julia pkg> add LinearOperators pkg> test LinearOperators ``` -------------------------------- ### Install and Test LinearOperators.jl Package in Julia Source: https://github.com/juliasmoothoptimizers/linearoperators.jl/blob/main/README.md This snippet demonstrates how to add the LinearOperators.jl package to your Julia environment using the built-in package manager. It also includes the command to run the package's tests, ensuring a successful and functional installation. ```Julia pkg> add LinearOperators pkg> test LinearOperators ``` -------------------------------- ### Run LinearOperators.jl Package Tests Source: https://github.com/juliasmoothoptimizers/linearoperators.jl/blob/main/docs/src/index.md Instructions for executing the test suite for the LinearOperators.jl package from the Julia REPL. This ensures the installed package functions as expected. ```Julia julia> Pkg.test("LinearOperators") ``` -------------------------------- ### LinearOperators.jl Utility Functions Source: https://github.com/juliasmoothoptimizers/linearoperators.jl/blob/main/README.md This section outlines various utility functions available in LinearOperators.jl for checking operator properties, converting operators, and managing L-BFGS/L-SR1 data. These functions extend the functionality of the operator classes, providing tools for analysis and manipulation. ```APIDOC check_ctranspose: Cheap check that A' is correctly implemented check_hermitian: Cheap check that A = A' check_positive_definite: Cheap check that an operator is positive (semi-)definite diag: Extract the diagonal of an operator Matrix: Convert an abstract operator to a dense array hermitian: Determine whether the operator is Hermitian push!: For L-BFGS or L-SR1 operators, push a new pair {s,y} reset!: For L-BFGS or L-SR1 operators, reset the data show: Display basic information about an operator size: Return the size of a linear operator symmetric: Determine whether the operator is symmetric normest: Estimate the 2-norm solve_shifted_system!: Solves linear system (B + sigma I) x = b, where B is a forward L-BFGS operator and sigma >= 0. ``` -------------------------------- ### Demonstrate Standard Julia Matrix Slicing Behavior Source: https://github.com/juliasmoothoptimizers/linearoperators.jl/blob/main/docs/src/index.md Illustrates that slicing a standard Julia matrix and multiplying by a scalar results in a `Vector`. This highlights a fundamental behavior difference from `LinearOperator`. ```Julia using LinearOperators A = rand(5,5) opA = LinearOperator(A) A[:,1] * 3 isa Vector ``` -------------------------------- ### Demonstrate LinearOperator vs Matrix Indexing and Multiplication in Julia Source: https://github.com/juliasmoothoptimizers/linearoperators.jl/blob/main/README.md This snippet illustrates the fundamental differences in behavior between a standard Julia Matrix (A) and a LinearOperator (opA) when performing indexing and multiplication operations. It shows how LinearOperator maintains its operator type even after slicing, unlike matrices which can reduce to vectors, and how it handles multiplication with vectors differently. ```JULIA A = rand(5,5) opA = LinearOperator(A) A[:,1] * 3 # Vector opA[:,1] * 3 # LinearOperator A[:,1] * [3] # ERROR opA[:,1] * [3] # Vector ``` -------------------------------- ### LinearOperators.jl Available Operator Types API Source: https://github.com/juliasmoothoptimizers/linearoperators.jl/blob/main/docs/src/index.md A comprehensive list of specialized linear operator types provided by LinearOperators.jl. This section details their purpose and how they extend the base `LinearOperator` functionality. ```APIDOC LinearOperator: Base class. Useful to define operators from functions TimedLinearOperator: Linear operator instrumented with timers from TimerOutputs BlockDiagonalOperator: Block-diagonal linear operator opEye: Identity operator opOnes: All ones operator opZeros: All zeros operator opDiagonal: Square (equivalent to diagm()) or rectangular diagonal operator opInverse: Equivalent to \\ opCholesky: More efficient than opInverse for symmetric positive definite matrices opLDL: Similar to opCholesky, for general sparse symmetric matrices opHouseholder: Apply a Householder transformation I-2hh' opHermitian: Represent a symmetric/hermitian operator based on the diagonal and strict lower triangle opRestriction: Represent a selection of "rows" when composed on the left with an existing operator opExtension: Represent a selection of "columns" when composed on the right with an existing operator LBFGSOperator: Limited-memory BFGS approximation in operator form (damped or not) InverseLBFGSOperator: Inverse of a limited-memory BFGS approximation in operator form (damped or not) LSR1Operator: Limited-memory SR1 approximation in operator form kron: Kronecker tensor product in linear operator form ``` -------------------------------- ### LinearOperators.jl Utility Functions API Source: https://github.com/juliasmoothoptimizers/linearoperators.jl/blob/main/docs/src/index.md A collection of utility functions provided by LinearOperators.jl for checking properties, converting, and manipulating linear operators. These functions enhance usability and integration. ```APIDOC check_ctranspose: Cheap check that A' is correctly implemented check_hermitian: Cheap check that A = A' check_positive_definite: Cheap check that an operator is positive (semi-)definite diag: Extract the diagonal of an operator Matrix: Convert an abstract operator to a dense array hermitian: Determine whether the operator is Hermitian push!: For L-BFGS or L-SR1 operators, push a new pair {s,y} reset!: For L-BFGS or L-SR1 operators, reset the data show: Display basic information about an operator size: Return the size of a linear operator symmetric: Determine whether the operator is symmetric normest: Estimate the 2-norm ``` -------------------------------- ### Compare Scalar Indexing of LinearOperator and Matrix in Julia Source: https://github.com/juliasmoothoptimizers/linearoperators.jl/blob/main/README.md This snippet further highlights the distinction between LinearOperator and standard matrices by demonstrating their behavior when indexed at a single scalar position. It shows that opA[1,1] returns a LinearOperator of size (1,1), while A[1,1] returns a scalar Number. ```JULIA opA[1,1] # LinearOperator A[1,1] # Number ``` -------------------------------- ### LinearOperators.jl Available Operator Classes Source: https://github.com/juliasmoothoptimizers/linearoperators.jl/blob/main/README.md This section lists the core linear operator classes provided by LinearOperators.jl, detailing their purpose and how they behave. These operators mimic matrix operations but are defined by their effect on vectors, allowing for efficient computation. ```APIDOC LinearOperator: Base class. Useful to define operators from functions TimedLinearOperator: Linear operator instrumented with timers from TimerOutputs BlockDiagonalOperator: Block-diagonal linear operator opEye: Identity operator opOnes: All ones operator opZeros: All zeros operator opDiagonal: Square (equivalent to diagm()) or rectangular diagonal operator opInverse: Equivalent to \ opCholesky: More efficient than opInverse for symmetric positive definite matrices opHouseholder: Apply a Householder transformation I-2hh' opHermitian: Represent a symmetric/hermitian operator based on the diagonal and strict lower triangle opRestriction: Represent a selection of "rows" when composed on the left with an existing operator opExtension: Represent a selection of "columns" when composed on the right with an existing operator LBFGSOperator: Limited-memory BFGS approximation in operator form (damped or not) InverseLBFGSOperator: Inverse of a limited-memory BFGS approximation in operator form (damped or not) LSR1Operator: Limited-memory SR1 approximation in operator form ``` -------------------------------- ### Demonstrate Error in Standard Matrix-Vector Multiplication Source: https://github.com/juliasmoothoptimizers/linearoperators.jl/blob/main/docs/src/index.md Highlights a common error encountered when attempting to multiply a sliced matrix (which becomes a vector) by another vector directly in Julia. ```Julia A[:,1] * [3] ``` -------------------------------- ### LinearOperators.jl General Operator Operations Source: https://github.com/juliasmoothoptimizers/linearoperators.jl/blob/main/README.md This section describes common mathematical operations that can be performed on LinearOperators.jl objects, including transposition, conjugation, and slicing. It highlights a key difference from standard matrices: slicing an operator always returns another operator. ```APIDOC Operators can be transposed (transpose(A)), conjugated (conj(A)) and conjugate-transposed (A'). Operators can be sliced (A[:,3], A[2:4,1:5], A[1,1]), but unlike matrices, slices always return operators (see differences below). ``` -------------------------------- ### Demonstrate LinearOperator Slicing Behavior Source: https://github.com/juliasmoothoptimizers/linearoperators.jl/blob/main/docs/src/index.md Shows that slicing a `LinearOperator` and multiplying by a scalar still yields a `LinearOperator`. This emphasizes that operators never reduce to vectors or numbers upon slicing. ```Julia opA[:,1] * 3 isa LinearOperator ``` -------------------------------- ### LinearOperator Slicing with Vector Multiplication Source: https://github.com/juliasmoothoptimizers/linearoperators.jl/blob/main/docs/src/index.md Illustrates that multiplying a sliced `LinearOperator` by a vector (not a scalar) can result in a standard Julia `Vector`. This demonstrates specific interaction behavior. ```Julia opA[:,1] * [3] isa Vector ``` -------------------------------- ### Accessing Single Element of a LinearOperator Source: https://github.com/juliasmoothoptimizers/linearoperators.jl/blob/main/docs/src/index.md Demonstrates that accessing a single element of a `LinearOperator` returns a (1,1) operator. This operator can then be used in subsequent calculations, maintaining consistency. ```Julia (opA[1,1] * [3])[1] - A[1,1] * 3 ``` -------------------------------- ### Convert Sliced LinearOperator to Dense Matrix Source: https://github.com/juliasmoothoptimizers/linearoperators.jl/blob/main/docs/src/index.md Shows how to explicitly convert a sliced `LinearOperator` back into a standard dense Julia matrix using the `Matrix()` function. This is useful for interoperability. ```Julia Matrix(opA[:,1]) ``` -------------------------------- ### Convert LinearOperator Slice to Matrix using full() in Julia Source: https://github.com/juliasmoothoptimizers/linearoperators.jl/blob/main/README.md This snippet demonstrates the use of the full() function to convert a LinearOperator slice into a standard Julia matrix. It shows that even a slice of a LinearOperator can be transformed into an nx1 matrix using this function, providing a way to retrieve the underlying matrix representation. ```JULIA full(opA[:,1]) # nx1 matrix ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.