Class: Mgmg::Vec
- Inherits:
-
Array
- Object
- Array
- Mgmg::Vec
- Defined in:
- lib/mgmg/utils.rb
Class Method Summary collapse
Instance Method Summary collapse
- #[]=(*arg) ⇒ Object
- #add!(other) ⇒ Object
- #e_div!(other) ⇒ Object
- #e_mul!(other) ⇒ Object
- #sub!(other) ⇒ Object
Class Method Details
.irange(size) ⇒ Object
325 326 327 |
# File 'lib/mgmg/utils.rb', line 325 def self.irange(size) Vec.new(size, &:itself) end |
Instance Method Details
#[]=(*arg) ⇒ Object
328 329 330 331 332 333 334 335 336 |
# File 'lib/mgmg/utils.rb', line 328 def []=(*arg) case arg.size when 1 self.replace(arg[0]) arg[0] else super end end |
#add!(other) ⇒ Object
273 274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/mgmg/utils.rb', line 273 def add!(other) case other when Array self.map!.with_index do |e, i| e + other[i] end else self.map! do |e| e + other end end self end |
#e_div!(other) ⇒ Object
312 313 314 315 316 317 318 319 320 321 322 323 324 |
# File 'lib/mgmg/utils.rb', line 312 def e_div!(other) case other when Array self.map!.with_index do |e, i| e.cdiv(other[i]) end else self.map! do |e| e.cdiv(other) end end self end |
#e_mul!(other) ⇒ Object
299 300 301 302 303 304 305 306 307 308 309 310 311 |
# File 'lib/mgmg/utils.rb', line 299 def e_mul!(other) case other when Array self.map!.with_index do |e, i| e * other[i] end else self.map! do |e| e * other end end self end |
#sub!(other) ⇒ Object
286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/mgmg/utils.rb', line 286 def sub!(other) case other when Array self.map!.with_index do |e, i| e - other[i] end else self.map! do |e| e - other end end self end |