Class: CAUnboundRepeat
- Inherits:
-
Object
- Object
- CAUnboundRepeat
- Defined in:
- lib/carray/runtime.rb
Instance Method Summary collapse
-
#template(*argv) { ... } ⇒ CAUnboundRepeat
Overrides CArray#template for unbound-repeat views.
Instance Method Details
#template(*argv) { ... } ⇒ CAUnboundRepeat
Overrides CArray#template for unbound-repeat views.
The C-level CArray#template allocates an entity sized to self.shape,
which for a CAUnboundRepeat would include the inflated unbound (:*)
axes — semantically wrong (unbound axes are not yet bound to a size)
and a memory bomb on broadcast patterns. Required for correctness.
This override allocates at the parent's compact shape instead, then
rewraps the result with the same spec so the returned view preserves
the unbound broadcast pattern.
105 106 107 |
# File 'lib/carray/runtime.rb', line 105 def template (*argv, &block) return parent.template(*argv,&block)[*spec.map{|x| x != :* ? nil : x}] end |