Info

This question is closed. Reopen it to edit or answer.

i have written code for sparse matrix multiplication and it is not giving me correct results when mutant is induced in the code, can anyone help me on this?

1 view (last 30 days)
please reply if anyone have a solution to this.
i have written the function for sparse matrix multiplication.
actually my aim is to test the function by introducing mutants in it. i have manually calculated the results which i must get when two particular values of matrices are multiplied, after introduction of mutant.
the mutant is:
we use C(i,j) = C(i,j) + (A(i,k) + B(k,j) instead of C(i,j) = C(i,j) + (A(i,k) * B(k,j) {standard formula for matrix multiplication} [* sign is replaced by +]
the system gives correct results with mutant when real numbers(0,1,2) are used as input but it does not give correct when fractional values are used (e.g 1.5, 0.25)result when.
code is given below:
function C=bsparse(A,B)
num_pts = 100;
%B = 2*A;
nzA = nnz(A);
nzB = nnz(B);
nzC_max = round(1.2*(nzA+nzB));
C = spalloc(num_pts,num_pts,nzC_max);
[iA,jA] = find(A);
[iB,jB] = find(B);
num_flops = 0;
for ielA = 1:nzA
for ielB = 1:nzB
if(iB(ielB)==jA(ielA))
i = iA(ielA);
k = jA(ielA);
j = jB(ielB);
%C(i,j) = C(i,j) + A(i,k)*B(k,j);//Mutant addistion is performed here
C(i,j) = C(i,j) + (A(i,k) + B(k,j));
num_flops = num_flops + 1;
end
end
end
end
  1 Comment
David Young
David Young on 15 Aug 2011
Please could you give a small example with values for A and B, the correct result according to your manual computation, and what your function gives as the result.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!