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

Function __clustered_common_final

src/modules/regress/clustered_errors.cpp:144–179  ·  view source on GitHub ↗

function used by linear and logistic finals

Source from the content-addressed store, hash-verified

142
143// function used by linear and logistic finals
144AnyType __clustered_common_final (AnyType& args)
145{
146 // In case the aggregator should be terminated because
147 // an exception has been "thrown" in the transition function
148 if (args[0].isNull())
149 return Null();
150 IClusteredState state = args[0].getAs<ByteString>();
151 if (state.numRows == 0) return Null();
152
153 Allocator& allocator = defaultAllocator();
154 SymmetricPositiveDefiniteEigenDecomposition<Matrix> decomposition(
155 state.bread, EigenvaluesOnly, ComputePseudoInverse);
156
157 int k = static_cast<int>(state.widthOfX);
158
159 Matrix meat(k, k);
160 meat = trans(state.meat_half) * state.meat_half;
161
162 MutableNativeColumnVector meatvec;
163 MutableNativeColumnVector breadvec;
164 meatvec.rebind(allocator.allocateArray<double>(k*k));
165 breadvec.rebind(allocator.allocateArray<double>(k*k));
166 int count = 0;
167 for (int i = 0; i < k; i++)
168 for (int j = 0; j < k; j++) {
169 meatvec(count) = meat(i,j);
170 breadvec(count) = state.bread(i,j);
171 count++;
172 }
173
174 AnyType tuple;
175
176 tuple << meatvec << breadvec;
177
178 return tuple;
179}
180
181// ------------------------------------------------------------------------
182

Callers 1

runMethod · 0.85

Calls 4

NullFunction · 0.85
transFunction · 0.85
isNullMethod · 0.45
rebindMethod · 0.45

Tested by

no test coverage detected