c++ - Solving system linear equation of small matrices via Cramer's rule has large numerical error -


i made observation when solve system of linear equation via cramer's rule (quotient of 2 determinants) of matrices of order n < 10, quite large residual error compared lapack solution.

here example:

float b00[36] __attribute__((aligned(16))) = {127.3611, -46.75962, 62.8739, -9.175959,   27.23792, 1.395347,                                              -46.75962,   841.5496, 406.2475, -119.3715, -33.60108, 6.269638,                                              62.8739,    406.2475,  1302.981, -542.8405,  95.03378, 42.77704,                                              -9.175959, -119.3715, -542.8405, 434.3342,   34.96918, -33.74546,                                              27.23792,  -33.60108,  95.03378, 34.96918,   59.10199, -1.880791,                                              1.395347,   6.269638,  42.77704, -33.74546, -1.880791, 2.650853};  float c00[6] __attribute__((aligned(16))) = {-0.102149, -5.76615, -17.02828, 12.47396, 1.158018, -0.9571021}; 

now linsolving this, yields lapack (from intel mkl):

x = [-0.000314947 -0.000589154 -0.00587876 0.0184799 0.01738 -0.0170484]

and cramer's rule (own implementation) yields:

x = [-0.000314933 -0.000798058 -0.00587888 0.0184808 0.017381 -0.0170508]

note x[1] difference.

i can guarantee determinant calculation of mine correct. has made similar observation or can tell this?


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -