mxArray *spqr_mx_put_sparse ( cholmod_sparse **Ahandle, // CHOLMOD version of the matrix cholmod_common *cc ) { mxArray *Amatlab ; cholmod_sparse *A ; Long nz, is_complex ; A = *Ahandle ; is_complex = (A->xtype != CHOLMOD_REAL) ; Amatlab = mxCreateSparse (0, 0, 0, is_complex ? mxCOMPLEX: mxREAL) ; mxSetM (Amatlab, A->nrow) ; mxSetN (Amatlab, A->ncol) ; mxSetNzmax (Amatlab, A->nzmax) ; mxFree (mxGetJc (Amatlab)) ; mxFree (mxGetIr (Amatlab)) ; mxFree (mxGetPr (Amatlab)) ; mxSetJc (Amatlab, (mwIndex *) A->p) ; mxSetIr (Amatlab, (mwIndex *) A->i) ; nz = cholmod_l_nnz (A, cc) ; put_values (nz, Amatlab, (double *) A->x, is_complex, cc) ; A->p = NULL ; A->i = NULL ; A->x = NULL ; A->z = NULL ; cholmod_l_free_sparse (Ahandle, cc) ; return (Amatlab) ; }
/*对缓存里的串分词并编码成utf-8输出*/ void output(){ put_values();//检索出特征值并初始化放在values数组里 dp();//动态规划搜索最优解放在result数组里 int c; for(int i=0;i<len;i++){ c=sequence[i]; if(c<128){//1个byte的utf-8 putchar(c); }else if(c<0x800){//2个byte的utf-8 putchar(0xc0|(c>>6)); putchar(0x80|(c&0x3f)); }else{//3个byte的utf-8
void output(){ put_values();//检索出特征值并初始化放在values数组里 dp();//动态规划搜索最优解放在result数组里 if(threshold==0){ output_sentence(); }else{ if(sl_decoder_show_sentence){ output_raw_sentence(); printf(" "); } cal_betas(); output_allow_cws(); } }
mxArray *spqr_mx_put_dense2 ( Long m, Long n, double *Ax, // size nz if real; size 2*nz if complex int is_complex, cholmod_common *cc ) { mxArray *A ; if (cc == NULL) return (NULL) ; A = mxCreateDoubleMatrix (0, 0, is_complex ? mxCOMPLEX : mxREAL) ; mxSetM (A, m) ; mxSetN (A, n) ; mxFree (mxGetPr (A)) ; mxFree (mxGetPi (A)) ; put_values (m*n, A, Ax, is_complex, cc) ; return (A) ; }
/** * Apply all the per-fragment operations to a span. * This now includes texturing (_swrast_write_texture_span() is history). * This function may modify any of the array values in the span. * span->interpMask and span->arrayMask may be changed but will be restored * to their original values before returning. */ void _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span) { const SWcontext *swrast = SWRAST_CONTEXT(ctx); const GLuint colorMask = *((GLuint *)ctx->Color.ColorMask); const GLbitfield origInterpMask = span->interpMask; const GLbitfield origArrayMask = span->arrayMask; const GLbitfield64 origArrayAttribs = span->arrayAttribs; const GLenum origChanType = span->array->ChanType; void * const origRgba = span->array->rgba; const GLboolean texture = ctx->Texture._EnabledCoord; struct gl_framebuffer *fb = ctx->DrawBuffer; /* printf("%s() interp 0x%x array 0x%x\n", __FUNCTION__, span->interpMask, span->arrayMask); */ ASSERT(span->primitive == GL_POINT || span->primitive == GL_LINE || span->primitive == GL_POLYGON || span->primitive == GL_BITMAP); /* Fragment write masks */ if (span->arrayMask & SPAN_MASK) { /* mask was initialized by caller, probably glBitmap */ span->writeAll = GL_FALSE; } else { memset(span->array->mask, 1, span->end); span->writeAll = GL_TRUE; } /* Clip to window/scissor box */ if (!clip_span(ctx, span)) { return; } ASSERT(span->end <= MAX_WIDTH); /* Depth bounds test */ if (ctx->Depth.BoundsTest && fb->Visual.depthBits > 0) { if (!_swrast_depth_bounds_test(ctx, span)) { return; } } #ifdef DEBUG /* Make sure all fragments are within window bounds */ if (span->arrayMask & SPAN_XY) { /* array of pixel locations */ GLuint i; for (i = 0; i < span->end; i++) { if (span->array->mask[i]) { assert(span->array->x[i] >= fb->_Xmin); assert(span->array->x[i] < fb->_Xmax); assert(span->array->y[i] >= fb->_Ymin); assert(span->array->y[i] < fb->_Ymax); } } } #endif /* Polygon Stippling */ if (ctx->Polygon.StippleFlag && span->primitive == GL_POLYGON) { stipple_polygon_span(ctx, span); } /* This is the normal place to compute the fragment color/Z * from texturing or shading. */ if (texture && !swrast->_DeferredTexture) { shade_texture_span(ctx, span); } /* Do the alpha test */ if (ctx->Color.AlphaEnabled) { if (!_swrast_alpha_test(ctx, span)) { /* all fragments failed test */ goto end; } } /* Stencil and Z testing */ if (ctx->Stencil._Enabled || ctx->Depth.Test) { if (!(span->arrayMask & SPAN_Z)) _swrast_span_interpolate_z(ctx, span); if (ctx->Stencil._Enabled) { /* Combined Z/stencil tests */ if (!_swrast_stencil_and_ztest_span(ctx, span)) { /* all fragments failed test */ goto end; } } else if (fb->Visual.depthBits > 0) { /* Just regular depth testing */ ASSERT(ctx->Depth.Test); ASSERT(span->arrayMask & SPAN_Z); if (!_swrast_depth_test_span(ctx, span)) { /* all fragments failed test */ goto end; } } } /* We had to wait until now to check for glColorMask(0,0,0,0) because of * the occlusion test. */ if (colorMask == 0) { /* no colors to write */ goto end; } /* If we were able to defer fragment color computation to now, there's * a good chance that many fragments will have already been killed by * Z/stencil testing. */ if (texture && swrast->_DeferredTexture) { shade_texture_span(ctx, span); } #if CHAN_BITS == 32 if ((span->arrayAttribs & FRAG_BIT_COL0) == 0) { interpolate_active_attribs(ctx, span, FRAG_BIT_COL0); } #else if ((span->arrayMask & SPAN_RGBA) == 0) { interpolate_int_colors(ctx, span); } #endif ASSERT(span->arrayMask & SPAN_RGBA); /* Fog */ if (swrast->_FogEnabled) { _swrast_fog_rgba_span(ctx, span); } /* Antialias coverage application */ if (span->arrayMask & SPAN_COVERAGE) { apply_aa_coverage(span); } /* * Write to renderbuffers. * Depending on glDrawBuffer() state and the which color outputs are * written by the fragment shader, we may either replicate one color to * all renderbuffers or write a different color to each renderbuffer. * multiFragOutputs=TRUE for the later case. */ { struct gl_renderbuffer *rb = fb->_ColorDrawBuffer; /* color[fragOutput] will be written to buffer */ if (rb) { struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); GLenum colorType = srb->ColorType; assert(colorType == GL_UNSIGNED_BYTE || colorType == GL_FLOAT); /* set span->array->rgba to colors for renderbuffer's datatype */ if (span->array->ChanType != colorType) { convert_color_type(span, colorType, 0); } else { if (span->array->ChanType == GL_UNSIGNED_BYTE) { span->array->rgba = span->array->rgba8; } else { span->array->rgba = (void *)span->array->attribs[FRAG_ATTRIB_COL]; } } ASSERT(rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB || rb->_BaseFormat == GL_RED || rb->_BaseFormat == GL_RG || rb->_BaseFormat == GL_ALPHA); if (ctx->Color.ColorLogicOpEnabled) { _swrast_logicop_rgba_span(ctx, rb, span); } else if (ctx->Color.BlendEnabled) { _swrast_blend_span(ctx, rb, span); } if (colorMask != 0xffffffff) { _swrast_mask_rgba_span(ctx, rb, span); } if (span->arrayMask & SPAN_XY) { /* array of pixel coords */ put_values(ctx, rb, span->array->ChanType, span->end, span->array->x, span->array->y, span->array->rgba, span->array->mask); } else { /* horizontal run of pixels */ _swrast_put_row(ctx, rb, span->array->ChanType, span->end, span->x, span->y, span->array->rgba, span->writeAll ? NULL: span->array->mask); } } /* if rb */ } end: /* restore these values before returning */ span->interpMask = origInterpMask; span->arrayMask = origArrayMask; span->arrayAttribs = origArrayAttribs; span->array->ChanType = origChanType; span->array->rgba = origRgba; }