Class: NumRu::CoordMapping

Inherits:
Object
  • Object
show all
Defined in:
lib/numru/gphys/coordmapping.rb

Direct Known Subclasses

LinearCoordMapping

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCoordMapping

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

#rankObject (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

#inverseObject



134
135
136
# File 'lib/numru/gphys/coordmapping.rb', line 134

def inverse
	 self.clone
end

#inverse_mapObject



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

Returns:

  • (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
	 expanded=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
	    expanded.push(x)
	 }
	 map(*expanded)
end