📄 gftrunc.c
字号:
/* ============================================================================ * Syntax: c = gftrunc(a, tp) *GFTRUNC Truncates redundant part of a GF(P) polynomial. * C = BFTRUNC(A) removes the zero coefficient from the highest order * terms from a GF(P) polynomial A. If the highest order term coefficient * is a non-zero number, the output of this function equals the input. * The resulted GF(P) polynomial C is the same as A with a shortened * form. * * The GF(P) polynomial A is in ascending order, i.e., * A = [a_0, a_1, a_2,..., a_(n-1), a_n] represents * A(X) = a_0 + a_1 X + a_2 X^2 +...+ a_(n-1) X^(n-1) + a_n X^n * a_i must be an element in GF(P). * * See also GFADD, GFDIV, GFTUPLE * ============================================================================ * Original designed by Wes Wang, * Jun Wu, The Mathworks, Inc. * Dec-12, 1995 * * Copyright (c) 1995-96 by The MAthWorks, Inc. * All Rights Reserved * $Revision: 1.1 $ $Date: 1996/04/01 18:14:41 $ * ============================================================================ */#include <math.h>#include "mex.h"#include "gflib.c"void mexFunction(int nlhs, Matrix *plhs[], int nrhs, Matrix *prhs[]){ int len_a, len_tp, i; int *paa, *Iwork; double *pa, *pc; pa = mxGetPr(prhs[0]); len_a = mxGetN(prhs[0])*mxGetM(prhs[0]); if(nrhs > 1) len_tp = mxGetN(prhs[1])*mxGetM(prhs[1]); else len_tp = 0; paa = (int *)mxCalloc(len_a, sizeof(int)); Iwork = (int *)mxCalloc(len_a, sizeof(int)); for (i=0; i < len_a; i++){ if(pa[i] == -mexGetInf() ) paa[i] = -Inf; else paa[i] = (int)pa[i]; } gftrunc(paa, &len_a, len_tp, Iwork); pc = mxGetPr(plhs[0] = mxCreateFull(1, len_a, 0)); for(i=0; i < len_a; i++){ if( paa[i] == -Inf ) pc[i] = -mexGetInf(); else pc[i] = (double)paa[i]; } return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -