Skip to content

Commit a4f8f70

Browse files
authored
Update tutorial.md
1 parent ce86206 commit a4f8f70

File tree

1 file changed

+1
-68
lines changed

1 file changed

+1
-68
lines changed

docs/src/tutorial.md

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1 @@
1-
# Tutorial
2-
3-
This page follows the Documenter.jl tutorial layout. It includes runnable examples for common usage patterns in LinearOperators.jl.
4-
5-
```@contents
6-
Pages = ["tutorial.md"]
7-
```
8-
9-
## Getting started
10-
11-
Calling into LinearOperators is simple:
12-
13-
```@docs
14-
using LinearOperators
15-
```
16-
17-
## Simple examples
18-
19-
Construct an operator from a matrix and use it like a matrix:
20-
21-
```@example ex_matrix
22-
using LinearOperators
23-
24-
A = [1.0 2.0; 3.0 4.0]
25-
op = LinearOperator(A)
26-
y = op * [1.0, 1.0]
27-
M = Matrix(op)
28-
println("y = ", y)
29-
println("Matrix(op) = \n", M)
30-
```
31-
32-
Create function-based operators (showing the 5-arg mul! signature):
33-
34-
```@example ex_fun
35-
n = 4
36-
function mymul!(res, v, α, β)
37-
if β == 0
38-
res .= α .* v .* (1:n)
39-
else
40-
res .= α .* v .* (1:n) .+ β .* res
41-
end
42-
end
43-
opfun = LinearOperator(Float64, n, n, false, false, mymul!)
44-
println(opfun * ones(n))
45-
```
46-
47-
Diagonal operators (use `opDiagonal`):
48-
49-
```@example ex_diag
50-
d = [2.0, 3.0, 4.0]
51-
D = opDiagonal(d)
52-
println(D * ones(3))
53-
```
54-
55-
Composing operators with vertical concatenation:
56-
57-
```@example ex_cat
58-
A = rand(3,3); B = rand(3,3)
59-
opA = LinearOperator(A); opB = LinearOperator(B)
60-
opcat = [opA; opB]
61-
println(size(opcat))
62-
```
63-
64-
## Return values and tips
65-
66-
- The `LinearOperator` type implements `*` and can be converted to a `Matrix` when necessary.
67-
- Prefer function-based operators when you want to avoid materializing large matrices.
68-
- See the full introduction: [Introduction to LinearOperators.jl](https://jso.dev/tutorials/introduction-to-linear-operators/)
1+
You can check an [Introduction to LinearOperators.jl](https://jso.dev/tutorials/introduction-to-linear-operators/) on our site, [jso.dev](https://jso.dev/).

0 commit comments

Comments
 (0)