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

Class ScalesState

src/modules/convex/utils_regularization.cpp:17–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15
16template <class Handle>
17class ScalesState
18{
19 template <class OtherHandle> friend class ScalesState;
20
21 public:
22 ScalesState (const AnyType& inArray):
23 mStorage(inArray.getAs<Handle>())
24 {
25 rebind();
26 }
27
28 inline operator AnyType () const
29 {
30 return mStorage;
31 }
32
33 inline void allocate (const Allocator& inAllocator,
34 uint32_t inDimension)
35 {
36 mStorage = inAllocator.allocateArray<double,
37 dbal::AggregateContext,
38 dbal::DoZero,
39 dbal::ThrowBadAlloc>(
40 arraySize(inDimension));
41 dimension.rebind(&mStorage[0]);
42 dimension = inDimension;
43 rebind();
44 }
45
46 template <class OtherHandle>
47 ScalesState& operator= (const ScalesState<OtherHandle>& inOtherState)
48 {
49 for (size_t i = 0; i < mStorage.size(); i++)
50 mStorage[i] = inOtherState.mStorage[i];
51 return *this;
52 }
53
54 static inline uint32_t arraySize (const uint32_t inDimension)
55 {
56 return 2 + 2 * inDimension;
57 }
58
59 protected:
60 void rebind ()
61 {
62 dimension.rebind(&mStorage[0]);
63 numRows.rebind(&mStorage[1]);
64 mean.rebind(&mStorage[2], dimension);
65 std.rebind(&mStorage[2 + dimension], dimension);
66 }
67
68 Handle mStorage;
69
70 public:
71 typename HandleTraits<Handle>::ReferenceToUInt32 dimension;
72 typename HandleTraits<Handle>::ReferenceToUInt64 numRows;
73 typename HandleTraits<Handle>::ColumnVectorTransparentHandleMap mean;
74 typename HandleTraits<Handle>::ColumnVectorTransparentHandleMap std;

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected