|
| 1 | +#pragma once |
| 2 | +// ============================================================ |
| 3 | +// Arrays specialized for short_float_t |
| 4 | +// |
| 5 | + |
| 6 | +namespace core { |
| 7 | + |
| 8 | +FORWARD(SimpleVector_short_float); |
| 9 | +FORWARD(MDArray_short_float); |
| 10 | +FORWARD(SimpleMDArray_short_float); |
| 11 | +FORWARD(ComplexVector_short_float); |
| 12 | + |
| 13 | +}; // namespace core |
| 14 | + |
| 15 | +template <> struct gctools::GCInfo<core::SimpleVector_short_float_O> { |
| 16 | + static bool constexpr NeedsInitialization = false; |
| 17 | + static bool constexpr NeedsFinalization = false; |
| 18 | + static GCInfo_policy constexpr Policy = atomic; |
| 19 | +}; |
| 20 | + |
| 21 | +namespace core { |
| 22 | +class SimpleVector_short_float_O; |
| 23 | + |
| 24 | +typedef template_SimpleVector<SimpleVector_short_float_O, short_float_t, AbstractSimpleVector_O> |
| 25 | + specialized_SimpleVector_short_float; |
| 26 | + |
| 27 | +class SimpleVector_short_float_O : public specialized_SimpleVector_short_float { |
| 28 | + LISP_CLASS(core, CorePkg, SimpleVector_short_float_O, "SimpleVector_short_float", AbstractSimpleVector_O); |
| 29 | + virtual ~SimpleVector_short_float_O() {}; |
| 30 | + |
| 31 | +public: |
| 32 | + typedef specialized_SimpleVector_short_float TemplatedBase; |
| 33 | + |
| 34 | + static value_type default_initial_element(void) { return short_float_t{0.0}; } |
| 35 | + static value_type from_object(T_sp obj) { return core::Number_O::as_short_float(obj.as<Number_O>()); }; |
| 36 | + static T_sp to_object(const value_type& v) { return core::ShortFloat_O::create(v); }; |
| 37 | + |
| 38 | + SimpleVector_short_float_O(size_t length, value_type initialElement = value_type(), bool initialElementSupplied = false, |
| 39 | + size_t initialContentsSize = 0, const value_type* initialContents = NULL) |
| 40 | + : TemplatedBase(length, initialElement, initialElementSupplied, initialContentsSize, initialContents) {}; |
| 41 | + static smart_ptr_type make(size_t length, value_type initialElement = value_type(), bool initialElementSupplied = false, |
| 42 | + size_t initialContentsSize = 0, const value_type* initialContents = NULL, |
| 43 | + bool static_vector_p = false) { |
| 44 | + auto bs = gctools::GC<my_type>::allocate_container<gctools::RuntimeStage>( |
| 45 | + static_vector_p, length, initialElement, initialElementSupplied, initialContentsSize, initialContents); |
| 46 | + return bs; |
| 47 | + } |
| 48 | + |
| 49 | + virtual T_sp element_type() const override { return cl::_sym_short_float; }; |
| 50 | + |
| 51 | + static SimpleVector_short_float_sp create(size_t sz) { return make(sz, short_float_t{0.0}, false, 0, NULL); } |
| 52 | + short_float_t& element(size_t i) { return this->operator[](i); }; |
| 53 | + short_float_t& getElement(size_t i) { return this->operator[](i); }; |
| 54 | + void setElement(size_t i, short_float_t v) { this->operator[](i) = v; }; |
| 55 | + void addToElement(size_t i, short_float_t v) { this->operator[](i) += v; }; |
| 56 | + void zero() { |
| 57 | + for (size_t i(0), iEnd(this->length()); i < iEnd; ++i) |
| 58 | + this->operator[](i) = short_float_t{0.0}; |
| 59 | + }; |
| 60 | + size_t size() const { return this->length(); }; |
| 61 | +}; |
| 62 | + |
| 63 | +class MDArray_short_float_O |
| 64 | + : public template_Array<MDArray_short_float_O, SimpleMDArray_short_float_O, SimpleVector_short_float_O, MDArray_O> { |
| 65 | + LISP_CLASS(core, CorePkg, MDArray_short_float_O, "MDArray_short_float", MDArray_O); |
| 66 | + virtual ~MDArray_short_float_O() {}; |
| 67 | + |
| 68 | +public: |
| 69 | + typedef template_Array<MDArray_short_float_O, SimpleMDArray_short_float_O, SimpleVector_short_float_O, MDArray_O> TemplatedBase; |
| 70 | + |
| 71 | + MDArray_short_float_O(size_t rank, List_sp dimensions, Array_sp data, bool displacedToP, Fixnum_sp displacedIndexOffset) |
| 72 | + : TemplatedBase(rank, dimensions, data, displacedToP, displacedIndexOffset) {}; |
| 73 | +}; |
| 74 | + |
| 75 | +class SimpleMDArray_short_float_O |
| 76 | + : public template_SimpleArray<SimpleMDArray_short_float_O, SimpleVector_short_float_O, SimpleMDArray_O> { |
| 77 | + LISP_CLASS(core, CorePkg, SimpleMDArray_short_float_O, "SimpleMDArray_short_float", SimpleMDArray_O); |
| 78 | + virtual ~SimpleMDArray_short_float_O() {}; |
| 79 | + |
| 80 | +public: |
| 81 | + typedef template_SimpleArray<SimpleMDArray_short_float_O, SimpleVector_short_float_O, SimpleMDArray_O> TemplatedBase; |
| 82 | + |
| 83 | + SimpleMDArray_short_float_O(size_t rank, List_sp dimensions, Array_sp data) : TemplatedBase(rank, dimensions, data) {}; |
| 84 | +}; |
| 85 | + |
| 86 | +class ComplexVector_short_float_O |
| 87 | + : public template_Vector<ComplexVector_short_float_O, SimpleVector_short_float_O, ComplexVector_O> { |
| 88 | + LISP_CLASS(core, CorePkg, ComplexVector_short_float_O, "ComplexVector_short_float", ComplexVector_O); |
| 89 | + virtual ~ComplexVector_short_float_O() {}; |
| 90 | + |
| 91 | +public: |
| 92 | + typedef template_Vector<ComplexVector_short_float_O, SimpleVector_short_float_O, ComplexVector_O> TemplatedBase; |
| 93 | + |
| 94 | + ComplexVector_short_float_O(size_t rank1, size_t dimension, T_sp fillPointer, Array_sp data, bool displacedToP, |
| 95 | + Fixnum_sp displacedIndexOffset) |
| 96 | + : TemplatedBase(dimension, fillPointer, data, displacedToP, displacedIndexOffset) {}; |
| 97 | + static smart_ptr_type make_vector(size_t dimension, simple_element_type initialElement /*=simple_element_type()*/, |
| 98 | + T_sp fillPointer /*=_Nil<T_O>()*/, T_sp dataOrDisplacedTo /*=_Nil<T_O>()*/, |
| 99 | + bool displacedToP /*=false*/, Fixnum_sp displacedIndexOffset /*=clasp_make_fixnum(0)*/) { |
| 100 | + LIKELY_if(dataOrDisplacedTo.nilp()) dataOrDisplacedTo = simple_type::make(dimension, initialElement, true); |
| 101 | + return gctools::GC<my_type>::allocate_container<gctools::RuntimeStage>( |
| 102 | + false, 1 /*CRANK*/, dimension, fillPointer, gc::As_unsafe<Array_sp>(dataOrDisplacedTo), displacedToP, displacedIndexOffset); |
| 103 | + } |
| 104 | + static smart_ptr_type make_vector(size_t dimension) { |
| 105 | + return make_vector(dimension, 0, nil<T_O>(), nil<T_O>(), false, clasp_make_fixnum(0)); |
| 106 | + } |
| 107 | + static smart_ptr_type make(size_t dimension, simple_element_type initialElement, bool initialElementSuppliedP, T_sp fillPointer, |
| 108 | + T_sp dataOrDisplacedTo, bool displacedToP, Fixnum_sp displacedIndexOffset) { |
| 109 | + (void)initialElementSuppliedP; |
| 110 | + return make_vector(dimension, initialElement, fillPointer, dataOrDisplacedTo, displacedToP, displacedIndexOffset); |
| 111 | + } |
| 112 | +}; |
| 113 | +}; // namespace core |
0 commit comments