* @brief Initialize the iteratively-reweighted-least-squares state. * * This function is only called for the first iteration, for the first row. */
| 83 | * This function is only called for the first iteration, for the first row. |
| 84 | */ |
| 85 | inline void initialize( |
| 86 | const Allocator &inAllocator, |
| 87 | uint16_t inWidthOfX, |
| 88 | uint16_t inNumCategories, uint16_t inRefCategory) { |
| 89 | |
| 90 | size_t state_size = arraySize(inWidthOfX, inNumCategories); |
| 91 | // GPDB limits the single array size to be 1GB, which means that the size |
| 92 | // of a double array cannot be large than 134217727 because |
| 93 | // (134217727 * 8) / (1024 * 1024) = 1023. And solve |
| 94 | // state_size = x^2 + 2^x + 6 <= 134217727 will give x <= 11584. |
| 95 | if(state_size > 134217727) |
| 96 | throw std::domain_error( |
| 97 | "The product of number of independent variables and number of " |
| 98 | "categories cannot be larger than 11584."); |
| 99 | |
| 100 | mStorage = inAllocator.allocateArray<double, dbal::AggregateContext, |
| 101 | dbal::DoZero, dbal::ThrowBadAlloc>(state_size); |
| 102 | rebind(inWidthOfX, inNumCategories); |
| 103 | widthOfX = inWidthOfX; |
| 104 | numCategories = inNumCategories; |
| 105 | ref_category = inRefCategory; |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * @brief We need to support assigning the previous state |