Sha256: 0db12392bd48a16f09767a6ba7f007ea00c88528edaff305d3624b30d992bda8

Contents?: true

Size: 905 Bytes

Versions: 9

Compression:

Stored size: 905 Bytes

Contents

class Array
  include TensorStream::MonkeyPatch

  def /(other)
    TensorStream.convert_to_tensor(self) * other
  end

  def %(other)
    TensorStream.convert_to_tensor(self) % other
  end

  def **(other)
    TensorStream.convert_to_tensor(self)**other
  end

  def max_index
    if first.is_a?(Float)
      highest = first
      highest_index = 0
      each_with_index do |item, index|
        next if item.nan?

        if item > highest
          highest = item
          highest_index = index
        end
      end
      highest_index
    else
      index(max)
    end
  end

  def min_index
    if first.is_a?(Float)
      highest = first
      highest_index = 0
      each_with_index do |item, index|
        next if item.nan?

        if item < highest
          highest = item
          highest_index = index
        end
      end
      highest_index
    else
      index(min)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
tensor_stream-1.0.9 lib/tensor_stream/monkey_patches/array.rb
tensor_stream-1.0.8 lib/tensor_stream/monkey_patches/array.rb
tensor_stream-1.0.7 lib/tensor_stream/monkey_patches/array.rb
tensor_stream-1.0.6 lib/tensor_stream/monkey_patches/array.rb
tensor_stream-1.0.5 lib/tensor_stream/monkey_patches/array.rb
tensor_stream-1.0.4 lib/tensor_stream/monkey_patches/array.rb
tensor_stream-1.0.3 lib/tensor_stream/monkey_patches/array.rb
tensor_stream-1.0.2 lib/tensor_stream/monkey_patches/array.rb
tensor_stream-1.0.1 lib/tensor_stream/monkey_patches/array.rb