Sha256: a4f8b5416a3cb6c4ed6eec3413cae45a644578d228d277e78fa7eab867f8aef8

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

module Silicium
  module Sparse
    # addition for SparseMatrix class
    class SparseMatrix
      ##
      # @param [SparseMatrix] other - second matrix for adding
      # @raise [ArgumentError] If the size of the first matrix doesn't match the size of the second matrix
      # @return [SparseMatrix] Matrix as the sum of the other two matrices
      #
      # Makes the sum of two matrix
      def +(other)
        adding(other)
      end

      ##
      # @param [SparseMatrix] other - second matrix for adding
      # @raise [ArgumentError] If the size of the first matrix doesn't match the size of the second matrix
      # @return [SparseMatrix] Matrix as the sum of the other two matrices
      #
      # Makes the sum of two matrix
      def -(other)
        adding(other.mult_by_num(-1))
      end

      ##
      # @param [SparseMatrix::Object] other - A matrix to multiply to
      # @raise [ArgumentError] if count of columns of right matrix
      # doesn't match count of rows of left matrix
      #
      # Returns a matrix in its regular view but multiplied by other matrix
      def *(other)
        multiply(other)
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
silicium-0.0.22 lib/silicium/sugar.rb
silicium-0.0.21 lib/silicium/sugar.rb