Class: MilkTea::Types::Matrix

Inherits:
Base
  • Object
show all
Defined in:
lib/milk_tea/core/types.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#accept, #bitwise?, #boolean?, #children, #field_c_name, #float?, #integer?, #sendable?, #void?

Constructor Details

#initialize(name, dim:) ⇒ Matrix

Returns a new instance of Matrix.



1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
# File 'lib/milk_tea/core/types.rb', line 1429

def initialize(name, dim:)
  @name = name
  @dim = dim
  @module_name = nil
  col_type = Vector.new("vec#{dim}", element_type: BUILTIN_VECTOR_ELEMENT, width: dim)
  @fields = (0...dim).each_with_object({}) do |i, h|
    h["col#{i}"] = col_type
  end.freeze
  @hash = [self.class, name].hash
  freeze
end

Instance Attribute Details

#dimObject (readonly)

Returns the value of attribute dim.



1427
1428
1429
# File 'lib/milk_tea/core/types.rb', line 1427

def dim
  @dim
end

#hashObject (readonly)

Returns the value of attribute hash.



1447
1448
1449
# File 'lib/milk_tea/core/types.rb', line 1447

def hash
  @hash
end

#module_nameObject (readonly)

Returns the value of attribute module_name.



1427
1428
1429
# File 'lib/milk_tea/core/types.rb', line 1427

def module_name
  @module_name
end

#nameObject (readonly)

Returns the value of attribute name.



1427
1428
1429
# File 'lib/milk_tea/core/types.rb', line 1427

def name
  @name
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


1441
1442
1443
# File 'lib/milk_tea/core/types.rb', line 1441

def eql?(other)
  other.is_a?(Matrix) && other.name == name
end

#field(name) ⇒ Object



1453
1454
1455
# File 'lib/milk_tea/core/types.rb', line 1453

def field(name)
  @fields[name]
end

#fieldsObject



1449
1450
1451
# File 'lib/milk_tea/core/types.rb', line 1449

def fields
  @fields
end

#numeric?Boolean

Returns:

  • (Boolean)


1457
1458
1459
# File 'lib/milk_tea/core/types.rb', line 1457

def numeric?
  true
end

#to_sObject



1462
1463
1464
# File 'lib/milk_tea/core/types.rb', line 1462

def to_s
  name
end