Class: NumRu::CoordMapping
- Inherits:
-
Object
- Object
- NumRu::CoordMapping
- Defined in:
- lib/numru/gphys/coordmapping.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#rank ⇒ Object
readonly
Returns the value of attribute rank.
Instance Method Summary collapse
-
#initialize ⇒ CoordMapping
constructor
A new instance of CoordMapping.
- #inverse ⇒ Object
- #inverse_map ⇒ Object
- #inversion_rigorous? ⇒ Boolean
- #map(*args) ⇒ Object
- #map_grid(*args) ⇒ Object
Constructor Details
#initialize ⇒ CoordMapping
Returns a new instance of CoordMapping.
97 98 99 100 |
# File 'lib/numru/gphys/coordmapping.rb', line 97 def initialize @rank = nil # nil means any (set a positive integer to specify) @inversion_rigorous = true end |
Instance Attribute Details
#rank ⇒ Object (readonly)
Returns the value of attribute rank.
102 103 104 |
# File 'lib/numru/gphys/coordmapping.rb', line 102 def rank @rank end |
Instance Method Details
#inverse ⇒ Object
134 135 136 |
# File 'lib/numru/gphys/coordmapping.rb', line 134 def inverse self.clone end |
#inverse_map ⇒ Object
112 113 114 115 |
# File 'lib/numru/gphys/coordmapping.rb', line 112 def inverse_map __check_args_m(*args) args.collect{|v| v.dup} end |
#inversion_rigorous? ⇒ Boolean
104 105 106 |
# File 'lib/numru/gphys/coordmapping.rb', line 104 def inversion_rigorous? @inversion_rigorous end |
#map(*args) ⇒ Object
108 109 110 111 |
# File 'lib/numru/gphys/coordmapping.rb', line 108 def map(*args) __check_args_m(*args) args.collect{|v| v.dup} end |
#map_grid(*args) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/numru/gphys/coordmapping.rb', line 117 def map_grid(*args) args.each{|v| raise ArgumentError,"all args must be 1D" if v.rank!=1} shape = args.collect{|v| v.length} rank = shape.length =Array.new (0...args.length).each{|i| to_insert = (0...i).collect{|j| 0} + ((i+1)...rank).collect{|j| 1} x = args[i] if to_insert.length > 0 x = x.newdim(*to_insert) x += NArray.float(*shape) end .push(x) } map(*) end |