static void __nlBeginMatrix() { NLuint i; NLuint n = 0; NLenum storage = __NL_ROWS; __nlTransition(__NL_STATE_SYSTEM, __NL_STATE_MATRIX); if (!__nlCurrentContext->solve_again) { for(i=0; i<__nlCurrentContext->nb_variables; i++) { if(!__nlCurrentContext->variable[i].locked) __nlCurrentContext->variable[i].index = n++; else __nlCurrentContext->variable[i].index = ~0; } __nlCurrentContext->n = n; /* a least squares problem results in a symmetric matrix */ if(__nlCurrentContext->least_squares) __nlCurrentContext->symmetric = NL_TRUE; if(__nlCurrentContext->symmetric) storage = (storage | __NL_SYMMETRIC); /* SuperLU storage does not support symmetric storage */ storage = (storage & ~__NL_SYMMETRIC); __nlSparseMatrixConstruct(&__nlCurrentContext->M, n, n, storage); __nlCurrentContext->alloc_M = NL_TRUE; __nlCurrentContext->x = __NL_NEW_ARRAY(NLfloat, n); __nlCurrentContext->alloc_x = NL_TRUE; __nlCurrentContext->b = __NL_NEW_ARRAY(NLfloat, n); __nlCurrentContext->alloc_b = NL_TRUE; } else { /* need to recompute b only, A is not constructed anymore */ __NL_CLEAR_ARRAY(NLfloat, __nlCurrentContext->b, __nlCurrentContext->n); } __nlVariablesToVector(); __nlRowColumnConstruct(&__nlCurrentContext->af); __nlCurrentContext->alloc_af = NL_TRUE; __nlRowColumnConstruct(&__nlCurrentContext->al); __nlCurrentContext->alloc_al = NL_TRUE; __nlCurrentContext->current_row = 0; }
static void __nlBeginMatrix() { NLuint i; NLuint m = 0, n = 0; NLenum storage = __NL_ROWS; __NLContext *context = __nlCurrentContext; __nlTransition(__NL_STATE_SYSTEM, __NL_STATE_MATRIX); if (!context->solve_again) { for(i=0; i<context->nb_variables; i++) { if(context->variable[i].locked) { context->variable[i].index = ~0; context->variable[i].a = __NL_NEW(__NLRowColumn); __nlRowColumnConstruct(context->variable[i].a); } else context->variable[i].index = n++; } m = (context->nb_rows == 0)? n: context->nb_rows; context->m = m; context->n = n; __nlSparseMatrixConstruct(&context->M, m, n, storage); context->alloc_M = NL_TRUE; context->b = __NL_NEW_ARRAY(NLfloat, m*context->nb_rhs); context->alloc_b = NL_TRUE; context->x = __NL_NEW_ARRAY(NLfloat, n*context->nb_rhs); context->alloc_x = NL_TRUE; } else { /* need to recompute b only, A is not constructed anymore */ __NL_CLEAR_ARRAY(NLfloat, context->b, context->m*context->nb_rhs); } __nlVariablesToVector(); }