However, when I tried to print this matrix P using "printf", eventhough the numbers are perfect, I got an error like this: *** stack smashing detected ***Ĭonst int nx = 5 // number of elements in x-directionĬonst int ny = 5 // number of elements in x-directionįor (int yrange = 1 yrange<=ny yrange++) ĭouble AreaMain, AreaPAB, AreaPBC, AreaPAC ĭouble semipMain = (lengthAB + lengthAC + lengthBC)/2.0 ĭouble semipPAB = (lengthPA + lengthPB + lengthAB)/2.0 ĭouble semipPBC = (lengthPB + lengthPC + lengthBC)/2.0 ĭouble semipPAC = (lengthPA + lengthPC + lengthAC)/2.0 ĪreaMain = sqrt(semipMain*(semipMain - lengthAB)*(semipMain - lengthAC)*(semipMain - lengthBC)) ĪreaPAB = sqrt(semipPAB*(semipPAB - lengthPA)*(semipPAB - lengthPB)*(semipPAB - lengthAB)) ĪreaPBC = sqrt(semipPBC*(semipPBC - lengthPB)*(semipPBC - lengthPC)*(semipPBC - lengthBC)) ĪreaPAC = sqrt(semipPAC*(semipPAC - lengthPA)*(semipPAC - lengthPC)*(semipPAC - lengthAC)) The final matrix result, P, I got, is correct. I declared it as a 2d array of length nx and ny. In my code, you can see below, P is a function of both x and y. I am solving the Laplace equation using C++.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |