//returns two column vectors linearly independent and spans the range space CplxMatrix CplxMatrix::range() const{ CplxMatrix toSolve = rowReduce(); int *freePos = new int[c+1]; int pivotCount = 0; for (int i = 0; i < c+1; i++) { freePos[i] = 0; } int tempindi = 0; int tempindj = 0; for (int i = 0; tempindi < r&&tempindj < c; i++) {//find the columns that have pivot if(toSolve.el(tempindi, tempindj).re==1&&toSolve.el(tempindi, tempindj).im==0){ tempindi++;tempindj++; pivotCount++; }else{ freePos[tempindj] = 1; tempindj++; } } CplxMatrix result(r, pivotCount); int writeInd = 0; for (int i = 0; i < c; i++) {//copy the original corresponding column to the result matrix if (freePos[i]==0) { for (int j = 0; j < r; j++) { result.el(j, writeInd) = el(j, i); } writeInd++; } } delete[] freePos; freePos = 0; return result; }
int appendCodedPayload(decoderstate* state, uint8_t* coeffsVector, uint8_t* dataVector, int blockNo) { do_debug("in appendCodedPayload\n"); int i, index, isEmpty = true; uint8_t factor; // Index = index of the first non-zero element for(index=0; index <= BLKSIZE; index++) { if(index == BLKSIZE) { return false; } if(coeffsVector[index] != 0x00) { break; } } // is the row[index] empty ? for(i=0; i < BLKSIZE; i++) { if(state->coefficients[blockNo]->data[index][i] != 0x00) { isEmpty = false; break; } } if(isEmpty) { // Append reduced factor = coeffsVector[index]; rowReduce(coeffsVector, factor, BLKSIZE); rowReduce(dataVector, factor, PACKETSIZE); memcpy(state->blocks[blockNo]->data[index], dataVector, PACKETSIZE); memcpy(state->coefficients[blockNo]->data[index], coeffsVector, BLKSIZE); state->nPacketsInBlock[blockNo] ++; return true; } else { // Try to eliminate factor = coeffsVector[index]; rowMulSub(coeffsVector, state->coefficients[blockNo]->data[index], factor, BLKSIZE); rowMulSub(dataVector, state->blocks[blockNo]->data[index], factor, PACKETSIZE); // Recursive call return appendCodedPayload(state, coeffsVector, dataVector, blockNo); } }
//hepler function to show steps for row reduce CplxMatrix CplxMatrix::rowReduceShowSteps() const{ return rowReduce(true); }