Open jdjshx opened 8 years ago
@jdjshx I changed the test_jacobi script to use the same A,b you had in your testing C file. I do not get a seg fault, instead I get NaN error:
FAIL: test_solve_jacobi (__main__.TestSolver)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_homework2.py", line 279, in test_solve_jacobi
self.assertAlmostEqual(error,0)
AssertionError: nan != 0 within 7 places
Make sure you are initializing all the arrays you are using to 0.0 before using them, and work out your jacobi loop by hand. Do you see any places where you are using garbage values?
@mvelegar Sorry, it is my bad, I have updated my newest version. Could you look at it again?
@jdjshx holding OH now with a lot of questions. I cannot promise to get the time to look at it again, I'll try my best
There is a common error floating around where students forget to zero out the memory pointed to by out
in their definition of mat_vec
...
...many related issues have come from this overlook.
I test my jacobi method in C file and I can get the correct answer. But when I make test in python, there is a segmentation fault (core dumped). I am confused here since if there is something wrong with my memory allocation, then I can not get the correct answer by directly calling jacobi method in C file 's main(). Could u look at my code, give me some hints about what's wrong with my code.