Complex
Complex is a library for types and mathematical functions for complex numbers.
Each complex number is represented as a structure holding the real and imaginary part. There are functions for creation and manipulation of them. Unfortunately since there is n operator overloading in Elixir the math functions (add, subtract, etc.) are implemented as add/2, sub/2, etc.
Installation
Add complex as a dependency in your mix.exs
file.
def deps do
[ { :complex, "~> 0.2.0" } ]
end
After you are done, run mix deps.get
in your shell to fetch and compile
Complex. Start an interactive Elixir shell with iex -S mix
and try the examples
in the examples section.
Documentation
Documentation for the package is available online via Hex at http://hexdocs.pm/complex. You can also generate local docs via the mix task
mix docs
This will generate the HTML documentation and place it into the doc
subdirectory.
Examples
iex> Complex.new(3, 4)
%Complex{im: 4, re: 3}
iex> Complex.imag()
%Complex{im: 1.0, re: 0.0}
License
Copyright 2015 Thomas Krauss
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.