Skip to content

Commit 65f9843

Browse files
committed
Add core/indef.
1 parent ae05949 commit 65f9843

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

core/private/Contents.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
% hessfull01 - Totally nonnegative lower Hessenberg Toeplitz matrix.
1616
% hessmaxdet - Upper Hessenberg matrix with maximal determinant.
1717
% hess_sublu - Upper Hessengerg matrix giving subnormal numbers in LU factor.
18+
% indef - Symmetric indefinite matrix with known inertia.
1819
% kms_nonsymm - Nonsymmetric Kac-Murdock-Szego Toeplitz matrix.
1920
% milnes - Upper triangle 1s and constant columnss in lower triangle.
2021
% nilpot_tridiag - Nilpotent tridiagonal matrix (sparse).

core/private/indef.m

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
function [A,properties] = indef(n,r)
2+
%INDEF Symmetric indefinite matrix with known inertia.
3+
% A = INDEF(n,r) is the n-by-n matrix with (i,j) element
4+
% (p(i) + p(j))^r, where r is nonnegative and p(i) = i/n.
5+
% r defaults to 2.
6+
% A = INDEF(p,r) has (i,j) element (p(i) + p(j))^r, where
7+
% p is an input vector of distinct positive entries.
8+
% If r is an integer with 0 <= r <= n-1 then A has
9+
% - ceil( (r+1)/2 ) positive eigenvalues,
10+
% - floor( (r+1)/2 ) negative eigenvalues, and
11+
% - n - r - 1 zero eigenvalues.
12+
% If r >= n-1 then A has
13+
% - ceil(n/2) positive eigenvalues,
14+
% - floor(n/2) negative eigenvalues.
15+
% The inertia is also known for real r with 0 < r < n-2.
16+
17+
% Reference:
18+
% Rajendra Bhatia and Tanvi Jain, Inertia of the Matrix (p_i+p_j)^r],
19+
% J. Spectr. Theory, 5(1), 71-78, 2015.
20+
21+
properties = {'symmetric', 'indefinite', 'positive'};
22+
if nargin == 0, A = []; return, end
23+
24+
p = n;
25+
if length(p) == 1
26+
p = (1:n)'/n;
27+
end
28+
if nargin < 2, r = 2; end
29+
A = (p + p').^r;

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ The following matrices have been added since v1.0.
2626
- core/collatz
2727
- core/cross
2828
- core/hess_sublu
29+
- core/indef
2930
- core/milnes
3031
- core/orthog_cauchy
3132
- core/pick

0 commit comments

Comments
 (0)