Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
juliohm committed Jul 18, 2021
1 parent 23d21df commit 1779ff3
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,24 @@ Compositions are static vectors with named parts:

```julia
julia> using CoDa
julia> cₒ = Composition(CO₂=1.0, CH₄=0.1, N₂O=0.1)
3-part composition
┌ ┐
CO₂ ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1.0
CH₄ ┤■■■■ 0.1
N₂O ┤■■■■ 0.1
└ ┘

julia> c = Composition(CO₂=2.0, CH₄=0.1, N₂O=0.3)
3-part composition
┌ ┐
CO₂ ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 2.0
CH₄ ┤■■ 0.1
N₂O ┤■■■■■ 0.3
└ ┘

julia> parts(c)
(:CO₂, :CH₄, :N₂O)

julia> components(c)
3-element StaticArrays.SVector{3, Union{Missing, Float64}} with indices SOneTo(3):
2.0
0.1
0.3

julia> c.CO₂
2.0
```
Expand All @@ -81,31 +85,44 @@ scalars. Other operations are also defined including dot product,
induced norm, and distance:

```julia
julia> cₒ = Composition(CO₂=1.0, CH₄=0.1, N₂O=0.1)
3-part composition
┌ ┐
CO₂ ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 1.0
CH₄ ┤■■■■ 0.1
N₂O ┤■■■■ 0.1
└ ┘

julia> -cₒ
3-part composition
┌ ┐
CO₂ ┤■■ 0.047619047619047616
CH₄ ┤■■■■■■■■■■■■■■■■■■■ 0.47619047619047616
N₂O ┤■■■■■■■■■■■■■■■■■■■ 0.47619047619047616
└ ┘

julia> 0.5c
3-part composition
┌ ┐
CO₂ ┤■■■■■■■■■■■■■■■■■■■■ 0.6207690197922022
CH₄ ┤■■■■ 0.13880817265812764
N₂O ┤■■■■■■■■ 0.24042280754967013
└ ┘

julia> c - cₒ
3-part composition
┌ ┐
CO₂ ┤■■■■■■■■■■■■■■■■■■■■■■■ 0.3333333333333333
CH₄ ┤■■■■■■■■■■■■ 0.16666666666666666
N₂O ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 0.5
└ ┘

julia> c cₒ
3.7554028908352994

julia> norm(c)
2.1432393747688687

julia> distance(c, cₒ)
0.7856640352007868
```
Expand All @@ -125,6 +142,7 @@ their closure is approximately equal:
```julia
julia> c == c
true

julia> c == cₒ
false
```
Expand Down

0 comments on commit 1779ff3

Please sign in to comment.