MCPcopy Create free account
hub / github.com/apache/madlib / CLABTransitionState

Class CLABTransitionState

src/modules/stats/clustered_variance_coxph.cpp:26–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24
25template <class Handle>
26class CLABTransitionState {
27
28 template <class OtherHandle>
29 friend class CLABTransitionState;
30
31 public:
32 CLABTransitionState(const AnyType &inArray)
33 : mStorage(inArray.getAs<Handle>()) {
34 rebind(static_cast<uint16_t>(mStorage[1]));
35 }
36
37 /**
38 * @brief Convert to backend representation
39 *
40 * We define this function so that we can use TransitionState in the argument
41 * list and as a return type. */
42 inline operator AnyType() const {
43 return mStorage;
44 }
45
46 /**
47 * @brief Initialize the transition state. Only called for first row.
48 *
49 * @param inAllocator Allocator for the memory transition state. Must fill
50 * the memory block with zeros.
51 * @param inWidthOfX Number of independent variables. The first row of data
52 * determines the size of the transition state. This size is a quadratic
53 * function of inWidthOfX.
54 */
55 inline void initialize(const Allocator &inAllocator, uint16_t inWidthOfX) {
56 mStorage = inAllocator.allocateArray<
57 double, dbal::AggregateContext, dbal::DoZero, dbal::ThrowBadAlloc>(
58 arraySize(inWidthOfX));
59 rebind(inWidthOfX);
60 widthOfX = inWidthOfX;
61 this->reset();
62 }
63
64 /**
65 * @brief Reset the inter-iteration fields.
66 */
67 inline void reset() {
68 numRows = 0;
69 A = 0;
70 B.fill(0);
71 }
72
73 private:
74 static inline size_t arraySize(const uint16_t inWidthOfX) {
75 return 3 + inWidthOfX;
76 }
77
78 void rebind(uint16_t inWidthOfX) {
79 numRows.rebind(&mStorage[0]);
80 widthOfX.rebind(&mStorage[1]);
81 A.rebind(&mStorage[2]);
82 B.rebind(&mStorage[3], inWidthOfX);
83 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected