i ran into an unexpected assertion error for this part, apparently @assertdidn’t evaluate the assert code line for some reason, and i’m getting for this part:

AssertionError: n0 == ones(n)
Stacktrace:
[1] top-level scope at In[15]:4

Of course it still throws the same assertion error. The @show statements are only there to make it easier to see why the assertion fails. (Look at the last element of each vector.)

You will need to rethink how you compute n. If this is a homework assignment, then read the text very carefully. Right now you compute n to be the number of nonzeros in all of MAT. Was this what you were asked to do? Maybe the task was to count only at the beginning of MAT?

it’s not a homework actually it’s a piece of code from a big code where i’m having problems with, and yes n is the number of nonzeros in all of MAT , after computing n0 i want to make it as ones(n)