Skip to content

Commit 41745e8

Browse files
authored
Add new types to readme (#111)
* Add new types to readme * Update readme for new show * Array in readme * Lucky 7 (for clarity)
1 parent 760afe4 commit 41745e8

File tree

1 file changed

+38
-39
lines changed

1 file changed

+38
-39
lines changed

README.md

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
[![Build Status](https://travis-ci.org/JuliaArrays/FillArrays.jl.svg?branch=master)](https://travis-ci.org/JuliaArrays/FillArrays.jl)
44
[![codecov](https://codecov.io/gh/JuliaArrays/FillArrays.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaArrays/FillArrays.jl)
55

6-
Julia package to lazily representing matrices filled with a single entry,
7-
as well as identity matrices. This package exports the following types: `Eye`,
8-
`Fill`, `Ones`, and `Zeros`.
6+
Julia package to lazily represent matrices filled with a single entry,
7+
as well as identity matrices. This package exports the following types:
8+
`Eye`, `Fill`, `Ones`, `Zeros`, `Trues` and `Falses`.
99

1010

1111
The primary purpose of this package is to present a unified way of constructing
@@ -21,45 +21,33 @@ julia> BandedMatrix(Zeros(5,5), (1, 2))
2121

2222
## Usage
2323

24-
Here are the matrix type4s:
24+
Here are the matrix types:
2525
```julia
2626
julia> Zeros(5, 6)
27-
5×6 Zeros{Float64,2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}}:
28-
0.0 0.0 0.0 0.0 0.0 0.0
29-
0.0 0.0 0.0 0.0 0.0 0.0
30-
0.0 0.0 0.0 0.0 0.0 0.0
31-
0.0 0.0 0.0 0.0 0.0 0.0
32-
0.0 0.0 0.0 0.0 0.0 0.0
33-
34-
julia> Zeros{Int}(5, 6)
35-
5×6 Zeros{Int64,2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}}:
36-
0 0 0 0 0 0
37-
0 0 0 0 0 0
38-
0 0 0 0 0 0
39-
0 0 0 0 0 0
40-
0 0 0 0 0 0
27+
5×6 Zeros{Float64}
28+
29+
julia> Zeros{Int}(2, 3)
30+
2×3 Zeros{Int64}
4131

4232
julia> Ones{Int}(5)
43-
5-element Ones{Int64,1,Tuple{Base.OneTo{Int64}}}:
44-
1
45-
1
46-
1
47-
1
48-
1
49-
50-
julia> Eye{Int}(5)
33+
5-element Ones{Int64}
34+
35+
julia> Eye{Int}(5)
5136
5×5 Diagonal{Int64,Ones{Int64,1,Tuple{Base.OneTo{Int64}}}}:
5237
1
5338
1
5439
1
5540
1
5641
1
5742

58-
julia> Fill(5.0f0, 3, 2)
59-
3×2 Fill{Float32,2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}}:
60-
5.0 5.0
61-
5.0 5.0
62-
5.0 5.0
43+
julia> Fill(7.0f0, 3, 2)
44+
3×2 Fill{Float32}: entries equal to 7.0
45+
46+
julia> Trues(2, 3)
47+
2×3 Ones{Bool}
48+
49+
julia> Falses(2)
50+
2-element Zeros{Bool}
6351
```
6452

6553
They support conversion to other matrix types like `Array`, `SparseVector`, `SparseMatrix`, and `Diagonal`:
@@ -74,16 +62,27 @@ julia> Matrix(Zeros(5, 5))
7462

7563
julia> SparseMatrixCSC(Zeros(5, 5))
7664
5×5 SparseMatrixCSC{Float64,Int64} with 0 stored entries
65+
66+
julia> Array(Fill(7, (2,3)))
67+
2×3 Array{Int64,2}:
68+
7 7 7
69+
7 7 7
7770
```
7871

79-
There is also support for offset index ranges:
72+
There is also support for offset index ranges,
73+
and the type includes the `axes`:
8074
```julia
8175
julia> Ones((-3:2, 1:2))
82-
Ones{Float64,2,Tuple{UnitRange{Int64},UnitRange{Int64}}} with indices -3:2×1:2:
83-
1.0 1.0
84-
1.0 1.0
85-
1.0 1.0
86-
1.0 1.0
87-
1.0 1.0
88-
1.0 1.0
76+
6×2 Ones{Float64,2,Tuple{UnitRange{Int64},UnitRange{Int64}}} with indices -3:2×1:2
77+
78+
julia> Fill(7, ((0:2), (-1:0)))
79+
3×2 Fill{Int64,2,Tuple{UnitRange{Int64},UnitRange{Int64}}} with indices 0:2×-1:0: entries equal to 7
80+
81+
julia> typeof(Zeros(5,6))
82+
Zeros{Float64,2,Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}}
8983
```
84+
85+
These types have methods that perform many operations efficiently,
86+
including elementary algebra operations like multiplication and addition,
87+
as well as linear algebra methods like
88+
`norm`, `adjoint`, `transpose` and `vec`.

0 commit comments

Comments
 (0)