carat
carat
A library for numerical and scientific computation. (Work in progress)
Installation
- Add the dependency to your
shard.yml
:
dependencies:
carat:
github: your-github-user/carat
- Run
shards install
Usage
require "carat"
Tensors
Carat defines class Tensor
which is (numpy-style) n-dimensional tensor.
Create tensor
It can be created in a number of ways:
- Tensor containing zeros
Tensor.new(2, 2) # [[ 0.0 0.0 ] # [ 0.0 0.0 ]]
- With block
Tensor.new(2, 2) do |i, j| (i + j).to_f end # [[ 0.0 1.0 ] # [ 1.0 2.0 ]]
- From a regular
Array
Tensor[2, 2].new([[0.0, 1.0], [1.0, 2.0]]) # [[ 0.0 1.0 ] # [ 1.0 2.0 ]]
Index tensor
- By integer
Ortensor = Tensor.new(3, 3) { |i, j| i + j } tensor[1, 1] # 2.0
tensor[1] # [ 1.0 2.0 3.0 ]
- By range
tensor[0...2, 0...2] # [[ 0.0 1.0 ] # [ 1.0 2.0 ]]
- By range with step
tensor[0..2..4, 0..2..4] # [[ 0.0 2.0 ] # [ 2.0 4.0 ]]
Development
TODO: Write development instructions here
Contributing
- Fork it (https://github.com/your-github-user/carat/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- Dmitriy Serdyuk - creator and maintainer
Repository
carat
Owner
Statistic
- 1
- 0
- 0
- 0
- 0
- almost 7 years ago
- November 28, 2018
License
MIT License
Links
Synced at
Fri, 03 Oct 2025 20:42:30 GMT
Languages