static void node_composit_exec_math(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { CompBuf *cbuf=in[0]->data; CompBuf *cbuf2=in[1]->data; CompBuf *stackbuf; /* check for inputs and outputs for early out*/ if(out[0]->hasoutput==0) return; /* no image-color operation */ if(in[0]->data==NULL && in[1]->data==NULL) { do_math(node, out[0]->vec, in[0]->vec, in[1]->vec); return; } /*create output based on first input */ if(cbuf) { stackbuf=alloc_compbuf(cbuf->x, cbuf->y, CB_VAL, 1); } /* and if it doesn't exist use the second input since we know that one of them must exist at this point*/ else { stackbuf=alloc_compbuf(cbuf2->x, cbuf2->y, CB_VAL, 1); } /* operate in case there's valid size */ composit2_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, in[1]->data, in[1]->vec, do_math, CB_VAL, CB_VAL); out[0]->data= stackbuf; }
// produce matrix with one row missing, for each possible row // Do some math on the new sub-matrix // Ben Klemens - MWD 4.6 static gsl_vector *jack_iteration(gsl_matrix *m, math_fn do_math){ int height = m->size1; gsl_vector *out = gsl_vector_alloc(height); apop_data *reduced = apop_data_alloc(0, (size_t)height - 1, (int)m->size2); Apop_submatrix(m, 1, 0, height - 1, m->size2, mv); gsl_matrix_memcpy(reduced->matrix, mv); for (int i=0; i< height; i++){ if (i % 100 == 0) std::cerr << "...jacknife at " << SeqLib::AddCommas(i) << " of " << SeqLib::AddCommas(height) << std::endl; gsl_vector_set(out, i, do_math(reduced)); // returns scalar output of do_math if (i < height - 1){ // create a new submatrix with new row ommited Apop_matrix_row(m, i, onerow); gsl_matrix_set_row(reduced->matrix, i, onerow); } } return out; }