diff options
author | Alberto Ruiz <aruiz@um.es> | 2010-12-30 18:07:39 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2010-12-30 18:07:39 +0000 |
commit | e503945c666dc28f1a806ba1a2deaa587a836200 (patch) | |
tree | f3971d4a8c9f4eaa4c508d8ffc6698fd31b6a8f6 /lib/Numeric/LinearAlgebra | |
parent | 853b46c522fa48a2c476fbfd0771a0da7aa9efc0 (diff) |
cond
Diffstat (limited to 'lib/Numeric/LinearAlgebra')
-rw-r--r-- | lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c | 22 | ||||
-rw-r--r-- | lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.h | 3 | ||||
-rw-r--r-- | lib/Numeric/LinearAlgebra/Tests.hs | 10 |
3 files changed, 34 insertions, 1 deletions
diff --git a/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c b/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c index ae437d2..f4ae0f6 100644 --- a/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c +++ b/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c | |||
@@ -1267,3 +1267,25 @@ int stepD(DVEC(x),DVEC(y)) { | |||
1267 | OK | 1267 | OK |
1268 | } | 1268 | } |
1269 | 1269 | ||
1270 | //////////////////// cond ///////////////////////// | ||
1271 | |||
1272 | int condF(FVEC(x),FVEC(y),FVEC(lt),FVEC(eq),FVEC(gt),FVEC(r)) { | ||
1273 | REQUIRES(xn==yn && xn==ltn && xn==eqn && xn==gtn && xn==rn ,BAD_SIZE); | ||
1274 | DEBUGMSG("condF") | ||
1275 | int k; | ||
1276 | for(k=0;k<xn;k++) { | ||
1277 | rp[k] = xp[k]<yp[k]?ltp[k]:(xp[k]>yp[k]?gtp[k]:eqp[k]); | ||
1278 | } | ||
1279 | OK | ||
1280 | } | ||
1281 | |||
1282 | int condD(DVEC(x),DVEC(y),DVEC(lt),DVEC(eq),DVEC(gt),DVEC(r)) { | ||
1283 | REQUIRES(xn==yn && xn==ltn && xn==eqn && xn==gtn && xn==rn ,BAD_SIZE); | ||
1284 | DEBUGMSG("condD") | ||
1285 | int k; | ||
1286 | for(k=0;k<xn;k++) { | ||
1287 | rp[k] = xp[k]<yp[k]?ltp[k]:(xp[k]>yp[k]?gtp[k]:eqp[k]); | ||
1288 | } | ||
1289 | OK | ||
1290 | } | ||
1291 | |||
diff --git a/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.h b/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.h index 6207a59..9526583 100644 --- a/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.h +++ b/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.h | |||
@@ -90,6 +90,9 @@ int conjugateC(KCVEC(x),CVEC(t)); | |||
90 | int stepF(FVEC(x),FVEC(y)); | 90 | int stepF(FVEC(x),FVEC(y)); |
91 | int stepD(DVEC(x),DVEC(y)); | 91 | int stepD(DVEC(x),DVEC(y)); |
92 | 92 | ||
93 | int condF(FVEC(x),FVEC(y),FVEC(lt),FVEC(eq),FVEC(gt),FVEC(r)); | ||
94 | int condD(DVEC(x),DVEC(y),DVEC(lt),DVEC(eq),DVEC(gt),DVEC(r)); | ||
95 | |||
93 | int svd_l_R(KDMAT(x),DMAT(u),DVEC(s),DMAT(v)); | 96 | int svd_l_R(KDMAT(x),DMAT(u),DVEC(s),DMAT(v)); |
94 | int svd_l_Rdd(KDMAT(x),DMAT(u),DVEC(s),DMAT(v)); | 97 | int svd_l_Rdd(KDMAT(x),DMAT(u),DVEC(s),DMAT(v)); |
95 | int svd_l_C(KCMAT(a),CMAT(u),DVEC(s),CMAT(v)); | 98 | int svd_l_C(KCMAT(a),CMAT(u),DVEC(s),CMAT(v)); |
diff --git a/lib/Numeric/LinearAlgebra/Tests.hs b/lib/Numeric/LinearAlgebra/Tests.hs index 181cfbf..76eaaae 100644 --- a/lib/Numeric/LinearAlgebra/Tests.hs +++ b/lib/Numeric/LinearAlgebra/Tests.hs | |||
@@ -369,7 +369,14 @@ findAssocTest = utest "findAssoc" ok | |||
369 | where | 369 | where |
370 | ok = m1 == m2 | 370 | ok = m1 == m2 |
371 | m1 = assoc (6,6) 7 $ zip (find (>0) (ident 5 :: Matrix Float)) [10 ..] :: Matrix Double | 371 | m1 = assoc (6,6) 7 $ zip (find (>0) (ident 5 :: Matrix Float)) [10 ..] :: Matrix Double |
372 | m2 = diagRect 7 (fromList[10..14]) 6 6 :: Matrix Double | 372 | m2 = diagRect 7 (fromList[10..14]) 6 6 |
373 | |||
374 | --------------------------------------------------------------------- | ||
375 | |||
376 | condTest = utest "cond" ok | ||
377 | where | ||
378 | ok = step v * v == cond v 0 0 0 v | ||
379 | v = fromList [-7 .. 7 ] :: Vector Float | ||
373 | 380 | ||
374 | --------------------------------------------------------------------- | 381 | --------------------------------------------------------------------- |
375 | 382 | ||
@@ -542,6 +549,7 @@ runTests n = do | |||
542 | , chainTest | 549 | , chainTest |
543 | , succTest | 550 | , succTest |
544 | , findAssocTest | 551 | , findAssocTest |
552 | , condTest | ||
545 | ] | 553 | ] |
546 | return () | 554 | return () |
547 | 555 | ||