Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 0 additions & 102 deletions src/vecffe.c
Original file line number Diff line number Diff line change
Expand Up @@ -900,108 +900,6 @@ Obj FuncADD_ROWVECTOR_VECFFES_2( Obj self, Obj vecL, Obj vecR )
return (Obj) 0;
}

/****************************************************************************
**
*F ProdVectorMatrix(<vecL>,<vecR>) . . . . product of a vector and a matrix
**
** 'ProdVectorMatrix' returns the product of the vector <vecL> and the matrix
** <vecR>. The product is the sum of the rows of <vecR>, each multiplied by
** the corresponding entry of <vecL>.
**
** 'ProdVectorMatrix' is an improved version of 'ProdListList', which does
** not call 'PROD' and also accumulates the sum into one fixed vector
** instead of allocating a new for each product and sum.
*/
Obj ProdVecFFEMatFFE (
Obj vecL,
Obj matR )
{
Obj vecP; /* handle of the product */
Obj * ptrP; /* pointer into the product */
FFV * ptrV; /* value pointer into the product */
FFV valP; /* one value of the product */
FFV valL; /* one value of the left operand */
Obj vecR; /* one vector of the right operand */
const Obj * ptrR; /* pointer into the right vector */
FFV valR; /* one value from the right vector */
UInt len; /* length */
UInt col; /* length of the rows in matR */
UInt i, k; /* loop variables */
FF fld; /* the common finite field */
const FFV * succ; /* the successor table */

/* check the lengths */
len = LEN_PLIST(vecL);
col = LEN_PLIST(ELM_PLIST(matR, 1));
if (len != LEN_PLIST(matR)) {
matR = ErrorReturnObj(
"<vec>*<mat>: <vec> (%d) must have the same length as <mat> (%d)",
(Int)len, (Int)col,
"you can replace matrix <mat> via 'return <mat>;'");
return PROD(vecL, matR);
}

/* check the fields */
vecR = ELM_PLIST(matR, 1);
fld = FLD_FFE(ELM_PLIST(vecL, 1));
if (FLD_FFE(ELM_PLIST(vecR, 1)) != fld) {
/* check the characteristic */
if (CHAR_FF(fld) == CHAR_FF(FLD_FFE(ELM_PLIST(vecR, 1))))
return ProdListList(vecL, matR);

matR = ErrorReturnObj(
"<vec>*<mat>: <vec> and <mat> have different fields",
0L, 0L,
"you can replace matrix <mat> via 'return <mat>;'");
return PROD(vecL, matR);
}

/* make the result list by multiplying the first entries */
vecP = ProdFFEVecFFE(ELM_PLIST(vecL, 1), vecR);

/* to add we need the successor table */
succ = SUCC_FF(fld);

/* convert vecP into a list of values */
/*N 5Jul1998 werner: This only works if sizeof(FFV) <= sizeof(Obj) */
/*N We have to be careful not to overwrite the length info */
ptrP = ADDR_OBJ(vecP);
ptrV = ((FFV*)(ptrP + 1)) - 1;
for (k = 1; k <= col; k++)
ptrV[k] = VAL_FFE(ptrP[k]);

/* loop over the other entries and multiply */
for (i = 2; i <= len; i++) {
valL = VAL_FFE(ELM_PLIST(vecL, i));
vecR = ELM_PLIST(matR, i);
ptrR = ADDR_OBJ(vecR);
if (valL == (FFV)1) {
for (k = 1; k <= col; k++) {
valR = VAL_FFE(ptrR[k]);
valP = ptrV[k];
ptrV[k] = SUM_FFV(valP, valR, succ);
}
} else if (valL != (FFV)0) {
for (k = 1; k <= col; k++) {
valR = VAL_FFE(ptrR[k]);
valR = PROD_FFV(valL, valR, succ);
valP = ptrV[k];
ptrV[k] = SUM_FFV(valP, valR, succ);
}
}
}

/* convert vecP back into a list of finite field elements */
/*N 5Jul1998 werner: This only works if sizeof(FFV) <= sizeof(Obj) */
/*N We have to be careful not to overwrite the length info */
for (k = col; k >= 1; k--)
ptrP[k] = NEW_FFE(fld, ptrV[k]);

/* return the result */
return vecP;
}


/****************************************************************************
**
*F ZeroVecFFE(<vec>) . . . . zero of an FFE Vector
Expand Down