Mercurial > hg > octave-nkf
changeset 9228:ab40ef1e232f
fix tests within eigs-base.cc
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 21 May 2009 10:13:39 +0200 |
parents | 8145f2255276 |
children | 579a19943d38 |
files | liboctave/ChangeLog liboctave/eigs-base.cc |
diffstat | 2 files changed, 135 insertions(+), 50 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,16 @@ +2009-05-20 Jaroslav Hajek <highegg@gmail.com> + + * eigs-base.cc ( + EigsRealSymmetricMatrix, + EigsRealSymmetricMatrixShift, + EigsRealSymmetricFunc, + EigsRealNonSymmetricMatrix, + EigsRealNonSymmetricMatrixShift, + EigsRealNonSymmetricFunc, + EigsComplexNonSymmetricMatrix, + EigsComplexNonSymmetricMatrixShift, + EigsComplexNonSymmetricFunc): Update tests. + 2009-05-21 Jaroslav Hajek <highegg@gmail.com>
--- a/liboctave/eigs-base.cc +++ b/liboctave/eigs-base.cc @@ -784,6 +784,13 @@ octave_rand::distribution(rand_dist); } + if (n < 3) + { + (*current_liboctave_error_handler) + ("eigs: n must be at least 3"); + return -1; + } + if (p < 0) { p = k * 2; @@ -794,18 +801,19 @@ if (p > n - 1) p = n - 1 ; } - else if (p <= k || p > n) + + if (k < 1 || k > n - 2) { (*current_liboctave_error_handler) - ("eigs: opts.p must be between k and n"); + ("eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1-1).\n" + " Use 'eig(full(A))' instead"); return -1; } - if (k > n ) + if (p <= k || p >= n) { (*current_liboctave_error_handler) - ("eigs: Too many eigenvalues to extract (k >= n).\n" - " Use 'eig(full(A))' instead"); + ("eigs: opts.p must be greater than k and less than n"); return -1; } @@ -1100,6 +1108,21 @@ octave_rand::distribution(rand_dist); } + if (n < 3) + { + (*current_liboctave_error_handler) + ("eigs: n must be at least 3"); + return -1; + } + + if (k <= 0 || k >= n - 1) + { + (*current_liboctave_error_handler) + ("eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1-1).\n" + " Use 'eig(full(A))' instead"); + return -1; + } + if (p < 0) { p = k * 2; @@ -1110,18 +1133,11 @@ if (p > n - 1) p = n - 1 ; } - else if (p <= k || p > n) + + if (p <= k || p >= n) { (*current_liboctave_error_handler) - ("eigs: opts.p must be between k and n"); - return -1; - } - - if (k > n ) - { - (*current_liboctave_error_handler) - ("eigs: Too many eigenvalues to extract (k >= n).\n" - " Use 'eig(full(A))' instead"); + ("eigs: opts.p must be greater than k and less than n"); return -1; } @@ -1401,6 +1417,13 @@ octave_rand::distribution(rand_dist); } + if (n < 3) + { + (*current_liboctave_error_handler) + ("eigs: n must be at least 3"); + return -1; + } + if (p < 0) { p = k * 2; @@ -1411,18 +1434,19 @@ if (p > n - 1) p = n - 1 ; } - else if (p <= k || p > n) + + if (k <= 0 || k >= n - 1) { (*current_liboctave_error_handler) - ("eigs: opts.p must be between k and n"); + ("eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1).\n" + " Use 'eig(full(A))' instead"); return -1; } - if (k > n ) + if (p <= k || p >= n) { (*current_liboctave_error_handler) - ("eigs: Too many eigenvalues to extract (k >= n).\n" - " Use 'eig(full(A))' instead"); + ("eigs: opts.p must be greater than k and less than n"); return -1; } @@ -1674,6 +1698,13 @@ octave_rand::distribution(rand_dist); } + if (n < 3) + { + (*current_liboctave_error_handler) + ("eigs: n must be at least 3"); + return -1; + } + if (p < 0) { p = k * 2 + 1; @@ -1684,18 +1715,19 @@ if (p > n - 1) p = n - 1 ; } - else if (p < k || p > n) + + if (k <= 0 || k >= n - 1) { (*current_liboctave_error_handler) - ("eigs: opts.p must be between k+1 and n"); + ("eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1).\n" + " Use 'eig(full(A))' instead"); return -1; } - if (k > n - 1) + if (p <= k || p >= n) { (*current_liboctave_error_handler) - ("eigs: Too many eigenvalues to extract (k >= n-1).\n" - " Use 'eig(full(A))' instead"); + ("eigs: opts.p must be greater than k and less than n"); return -1; } @@ -2032,6 +2064,13 @@ octave_rand::distribution(rand_dist); } + if (n < 3) + { + (*current_liboctave_error_handler) + ("eigs: n must be at least 3"); + return -1; + } + if (p < 0) { p = k * 2 + 1; @@ -2042,18 +2081,19 @@ if (p > n - 1) p = n - 1 ; } - else if (p < k || p > n) + + if (k <= 0 || k >= n - 1) { (*current_liboctave_error_handler) - ("eigs: opts.p must be between k+1 and n"); + ("eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1).\n" + " Use 'eig(full(A))' instead"); return -1; } - if (k > n - 1) + if (p <= k || p >= n) { (*current_liboctave_error_handler) - ("eigs: Too many eigenvalues to extract (k >= n-1).\n" - " Use 'eig(full(A))' instead"); + ("eigs: opts.p must be greater than k and less than n"); return -1; } @@ -2380,6 +2420,13 @@ octave_rand::distribution(rand_dist); } + if (n < 3) + { + (*current_liboctave_error_handler) + ("eigs: n must be at least 3"); + return -1; + } + if (p < 0) { p = k * 2 + 1; @@ -2390,18 +2437,19 @@ if (p > n - 1) p = n - 1 ; } - else if (p < k || p > n) + + if (k <= 0 || k >= n - 1) { (*current_liboctave_error_handler) - ("eigs: opts.p must be between k+1 and n"); + ("eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1).\n" + " Use 'eig(full(A))' instead"); return -1; } - if (k > n - 1) + if (p <= k || p >= n) { (*current_liboctave_error_handler) - ("eigs: Too many eigenvalues to extract (k >= n-1).\n" - " Use 'eig(full(A))' instead"); + ("eigs: opts.p must be greater than k and less than n"); return -1; } @@ -2697,6 +2745,13 @@ octave_rand::distribution(rand_dist); } + if (n < 3) + { + (*current_liboctave_error_handler) + ("eigs: n must be at least 3"); + return -1; + } + if (p < 0) { p = k * 2 + 1; @@ -2707,18 +2762,19 @@ if (p > n - 1) p = n - 1 ; } - else if (p < k || p > n) + + if (k <= 0 || k >= n - 1) { (*current_liboctave_error_handler) - ("eigs: opts.p must be between k+1 and n"); + ("eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1).\n" + " Use 'eig(full(A))' instead"); return -1; } - if (k > n - 1) + if (p <= k || p >= n) { (*current_liboctave_error_handler) - ("eigs: Too many eigenvalues to extract (k >= n-1).\n" - " Use 'eig(full(A))' instead"); + ("eigs: opts.p must be greater than k and less than n"); return -1; } @@ -3014,6 +3070,13 @@ octave_rand::distribution(rand_dist); } + if (n < 3) + { + (*current_liboctave_error_handler) + ("eigs: n must be at least 3"); + return -1; + } + if (p < 0) { p = k * 2 + 1; @@ -3024,18 +3087,19 @@ if (p > n - 1) p = n - 1 ; } - else if (p < k || p > n) + + if (k <= 0 || k >= n - 1) { (*current_liboctave_error_handler) - ("eigs: opts.p must be between k+1 and n"); + ("eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1).\n" + " Use 'eig(full(A))' instead"); return -1; } - if (k > n - 1) + if (p <= k || p >= n) { (*current_liboctave_error_handler) - ("eigs: Too many eigenvalues to extract (k >= n-1).\n" - " Use 'eig(full(A))' instead"); + ("eigs: opts.p must be greater than k and less than n"); return -1; } @@ -3323,6 +3387,13 @@ octave_rand::distribution(rand_dist); } + if (n < 3) + { + (*current_liboctave_error_handler) + ("eigs: n must be at least 3"); + return -1; + } + if (p < 0) { p = k * 2 + 1; @@ -3333,18 +3404,19 @@ if (p > n - 1) p = n - 1 ; } - else if (p < k || p > n) + + if (k <= 0 || k >= n - 1) { (*current_liboctave_error_handler) - ("eigs: opts.p must be between k+1 and n"); + ("eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1).\n" + " Use 'eig(full(A))' instead"); return -1; } - if (k > n - 1) + if (p <= k || p >= n) { (*current_liboctave_error_handler) - ("eigs: Too many eigenvalues to extract (k >= n-1).\n" - " Use 'eig(full(A))' instead"); + ("eigs: opts.p must be greater than k and less than n"); return -1; }