Project

einsum

0.0
No commit activity in last 3 years
No release in over 3 years
Unoptimized, pure-Ruby implementation of a subset of Numpy `einsum`.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 10.0
~> 0.12
~> 12.3.3
~> 3.8
~> 0.63
~> 0
 Project Readme

Einsum

Build Status Documentation

Unoptimized, pure-Ruby implementation of a subset of Numpy einsum.

See: https://docs.scipy.org/doc/numpy/reference/generated/numpy.einsum.html

Installation

Add this to your application's Gemfile:

gem 'einsum'

And then execute:

$ bundle

Or install it manually:

$ gem install einsum

Usage

Evaluates the (extended) Einstein summation convention on the operands.

Operands must be Array like. Array elements must respond to * and +.

Implicit mode:

Einsum.einsum('ij,jk', [[1, 2], [3, 4]], [[1, 2], [3, 4]]) # => dot product: [[7, 10], [15, 22]]
Einsum.einsum('ij,kj', [[1, 2], [3, 4]], [[1, 2], [3, 4]]) # => inner product: [[ 5, 11], [11, 25]]

Explicit mode:

Einsum.einsum('ij,jk->ik', [[1, 2], [3, 4]], [[1, 2], [3, 4]]) # => dot product: [[7, 10], [15, 22]]
Einsum.einsum('ij,kj->ik', [[1, 2], [3, 4]], [[1, 2], [3, 4]]) # => inner product: [[ 5, 11], [11, 25]]
Einsum.einsum('ij,jk->', [[1, 2], [3, 4]], [[1, 2], [3, 4]]) # => 54
Einsum.einsum('ij,kj->', [[1, 2], [3, 4]], [[1, 2], [3, 4]]) # => 52

Development

After checking out the repository, run bin/setup to install dependencies. Run bin/console for an interactive prompt. Run rake spec to run the tests.

To install this gem locally, run bundle exec rake install. To release a new version, update the version number in version.rb and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at (https://github.com/toddsundsted/einsum).

License

The gem is available as open source under the terms of the MIT License.