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

Method run

src/modules/convex/lmf_igd.cpp:40–111  ·  view source on GitHub ↗

* @brief Perform the low-rank matrix factorization transition step * * Called for each tuple. */

Source from the content-addressed store, hash-verified

38 * Called for each tuple.
39 */
40AnyType
41lmf_igd_transition::run(AnyType &args) {
42 // The real state.
43 // For the first tuple: args[0] is nothing more than a marker that
44 // indicates that we should do some initial operations.
45 // For other tuples: args[0] holds the computation state until last tuple
46 LMFIGDState<MutableArrayHandle<double> > state = args[0];
47
48 // initilize the state if first tuple
49 if (state.algo.numRows == 0) {
50 if (!args[4].isNull()) {
51 LMFIGDState<ArrayHandle<double> > previousState = args[4];
52 state.allocate(*this, previousState.task.rowDim,
53 previousState.task.colDim, previousState.task.maxRank);
54 state = previousState;
55 } else {
56 // configuration parameters
57 int32_t rowDim = args[5].getAs<int32_t>();
58 if (rowDim <= 0) {
59 throw std::runtime_error("Invalid parameter: row_dim <= 0");
60 }
61 int32_t columnDim = args[6].getAs<int32_t>();
62 if (columnDim <= 0) {
63 throw std::runtime_error("Invalid parameter: column_dim <= 0");
64 }
65 int32_t maxRank = args[7].getAs<int32_t>();
66 if (maxRank <= 0) {
67 throw std::runtime_error("Invalid parameter: max_rank <= 0");
68 }
69 if (maxRank >= rowDim || maxRank >= columnDim) {
70 throw std::runtime_error("Invalid parameter: "
71 "max_rank >= row_dim || max_rank >= column_dim");
72 }
73 double stepsize = args[8].getAs<double>();
74 if (stepsize <= 0.) {
75 throw std::runtime_error("Invalid parameter: stepsize <= 0.0");
76 }
77 double scaleFactor = args[9].getAs<double>();
78 if (scaleFactor <= 0.) {
79 throw std::runtime_error("Invalid parameter: "
80 "scale_factor <= 0.0");
81 }
82
83 state.allocate(*this, rowDim, columnDim, maxRank);
84 state.task.stepsize = stepsize;
85 state.task.scaleFactor = scaleFactor;
86 state.task.model.initialize(scaleFactor);
87 }
88 // resetting in either case
89 state.reset();
90 }
91
92 // tuple
93 LMFTuple tuple;
94 tuple.indVar.i = args[1].getAs<int32_t>();
95 tuple.indVar.j = args[2].getAs<int32_t>();
96 if (tuple.indVar.i == 0 || tuple.indVar.j == 0) {
97 throw std::runtime_error("Invalid parameter: [col_row] = 0 or "

Callers

nothing calls this directly

Calls 7

NullFunction · 0.85
transFunction · 0.85
computeRMSEMethod · 0.80
isNullMethod · 0.45
allocateMethod · 0.45
initializeMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected