/** * @param[in] space The list of points in space that need to be iterated. */ void operator() (const pfunc::space_1D& space) const { for (size_t i=space.begin(); i<space.end(); ++i) { EdgeListType edge_list = (*set_map)(i); RandomAccessContainer A (M*edge_list.size()); RandomAccessContainer X (edge_list.size()); /* Response is common across all the vertices */ int response; /* Set up A, X, and R */ EdgeListIteratorType list_iter = edge_list.begin (); int index=0; while (list_iter != edge_list.end()) { edge_type current_entry = (*list_iter); const snp_type snp = (*snp_map)(current_entry.source); response = current_entry.target; const float_type weight = current_entry.weight; /* populate A */ (*materializer)(snp, A.begin()+(index*M)); /* populate X */ X[index] = weight; /* populate R */ int int_M = static_cast<int>(M); double* Y_ptr = const_cast<double*>(&((*Y)[0])+(response*M)); double* R_ptr = const_cast<double*>(&((*R)[0])+(response*M)); dcopy_ (&int_M, Y_ptr, &ONE_STEP, R_ptr, &ONE_STEP); ++list_iter; ++index; } /* Now, compute R = AX-R */ double* A_ptr = &(A[0]); double* X_ptr = &(X[0]); double* R_ptr = &((*R)[0])+(response*M); int LDA = static_cast<int>(M); int LDX = static_cast<int>(edge_list.size()); int LDR = static_cast<int>(M); dgemm_ (&NO_TRANS, &NO_TRANS, &LDR, &ONE_STEP, &LDX, &PLUS_ONE, A_ptr, &LDA, X_ptr, &LDX, &MINUS_ONE, R_ptr, &LDR); (*l2_norm)[response] = dnrm2_(&LDR, R_ptr, &ONE_STEP); } }
/** * @param[in] space The list of candidates that need to be evaluated. */ void operator() (const pfunc::space_1D& space) { /* Loop over each element in the range that is given to us */ for (size_t i=space.begin(); i<space.end(); ++i) { const int candidate = (*map)(i); /* pass this candidate through the filter */ if ((*filter)(candidate)) continue; /* Materialize Xg */ A->materialize_X (candidate, Xg.begin()); /* Materialize Cholesky (Xg'Xg) */ factorizer->materialize (candidate, cholesky_XgtXg.begin()); /* Solve Ax=y, compute cost */ solver (Xg, cholesky_XgtXg); cost (Xg); /* Check if the new gain is worth switching over from the previous */ swap (value_type (candidate, (*weights)[candidate]*cost.get_result())); } }