Class: MilkTea::Types::Matrix

Inherits:
Base
  • Object
show all
Defined in:
lib/milk_tea/core/types/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.



1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
# File 'lib/milk_tea/core/types/types.rb', line 1440

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.



1438
1439
1440
# File 'lib/milk_tea/core/types/types.rb', line 1438

def dim
  @dim
end

#hashObject (readonly)

Returns the value of attribute hash.



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

def hash
  @hash
end

#module_nameObject (readonly)

Returns the value of attribute module_name.



1438
1439
1440
# File 'lib/milk_tea/core/types/types.rb', line 1438

def module_name
  @module_name
end

#nameObject (readonly)

Returns the value of attribute name.



1438
1439
1440
# File 'lib/milk_tea/core/types/types.rb', line 1438

def name
  @name
end

Instance Method Details

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

Returns:

  • (Boolean)


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

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

#field(name) ⇒ Object



1464
1465
1466
# File 'lib/milk_tea/core/types/types.rb', line 1464

def field(name)
  @fields[name]
end

#fieldsObject



1460
1461
1462
# File 'lib/milk_tea/core/types/types.rb', line 1460

def fields
  @fields
end

#numeric?Boolean

Returns:

  • (Boolean)


1468
1469
1470
# File 'lib/milk_tea/core/types/types.rb', line 1468

def numeric?
  true
end

#to_sObject



1473
1474
1475
# File 'lib/milk_tea/core/types/types.rb', line 1473

def to_s
  name
end