./PaxHeaders/linear-algebra-2.2.40000644000000000000000000000013215146653556013542 xustar0030 mtime=1771788142.208370755 30 atime=1771788142.227370642 30 ctime=1771788142.227370642 linear-algebra-2.2.4/0000755000175000017500000000000015146653556014000 5ustar00philipphiliplinear-algebra-2.2.4/PaxHeaders/inst0000644000000000000000000000013215146653556014362 xustar0030 mtime=1771788142.208370755 30 atime=1771788142.227370642 30 ctime=1771788142.227370642 linear-algebra-2.2.4/inst/0000755000175000017500000000000015146653556014755 5ustar00philipphiliplinear-algebra-2.2.4/inst/PaxHeaders/circulant_make_matrix.m0000644000000000000000000000006215146653315021155 xustar0020 atime=1771787981 30 ctime=1771788142.227370642 linear-algebra-2.2.4/inst/circulant_make_matrix.m0000644000175000017500000000437115146653315021476 0ustar00philipphilip## Copyright (C) 2012 Nir Krakauer ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn{Function File} {@var{C} =} circulant_make_matrix (@var{v}) ## Produce a full circulant matrix given the first column. ## ## @emph{Note:} this function has been deprecated and will be removed in the ## future. Instead, use @code{gallery} with the the @code{circul} option. ## To obtain the exactly same matrix, transpose the result, i.e., replace ## @code{circulant_make_matrix (@var{v})} with ## @code{gallery ("circul", @var{v})'}. ## ## Given an @var{n}*1 vector @var{v}, returns the @var{n}*@var{n} circulant ## matrix @var{C} where @var{v} is the left column and all other columns are ## downshifted versions of @var{v}. ## ## Note: If the first row @var{r} of a circulant matrix is given, the first ## column @var{v} can be obtained as @code{v = r([1 end:-1:2])}. ## ## Reference: Gene H. Golub and Charles F. Van Loan, Matrix Computations, 3rd Ed., Section 4.7.7 ## ## @seealso{gallery, circulant_matrix_vector_product, circulant_eig, circulant_inv} ## @end deftypefn function C = circulant_make_matrix(v) persistent warned = false; if (! warned) warned = true; warning ("Octave:deprecated-function", "`circulant_make_matrix (V)' has been deprecated in favor of `gallery (\"circul\", V)''. This function will be removed from future versions of the `linear-algebra' package"); endif n = numel(v); C = ones(n, n); for i = 1:n C(:, i) = v([(end-i+2):end 1:(end-i+1)]); #or circshift(v, i-1) endfor endfunction %!shared v,C %! v = [1 2 3]'; C = [1 3 2; 2 1 3; 3 2 1]; %!assert (circulant_make_matrix(v), C); linear-algebra-2.2.4/inst/PaxHeaders/__exit_linear_algebra__.m0000644000000000000000000000006215146653315021364 xustar0020 atime=1771787981 30 ctime=1771788142.227370642 linear-algebra-2.2.4/inst/__exit_linear_algebra__.m0000644000175000017500000000313015146653315021675 0ustar00philipphilip## Copyright (C) 2016-2026 CarnĂ« Draug ## Copyright (C) 2011-2026 Philip Nienhuis ## ## This program is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 3 of the ## License, or (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, see ## . ## -*- texinfo -*- ## @deftypefn {} {} __exit_linear_algebra__ () ## Undocumented internal function of linear_algebra package. ## ## Deregister Qt help files for GUI doc browser. ## ## @end deftypefn ## PKG_DEL: __exit_linear_algebra__ () function __exit_linear_algebra__ () ## Package documentation ## On package unload, attempt to unload docs try pkg_dir = fileparts (fullfile (mfilename ("fullpath"))); doc_file = fullfile (pkg_dir, "doc", "linear-algebra.qch"); doc_file = strrep (doc_file, '\', '/'); if exist(doc_file, "file") if exist("__event_manager_unregister_documentation__") __event_manager_unregister_documentation__ (doc_file); elseif exist("__event_manager_unregister_doc__") __event_manager_unregister_doc__ (doc_file); endif endif catch # do nothing end_try_catch endfunction linear-algebra-2.2.4/inst/PaxHeaders/smwsolve.m0000644000000000000000000000006215146653315016467 xustar0020 atime=1771787981 30 ctime=1771788142.227370642 linear-algebra-2.2.4/inst/smwsolve.m0000644000175000017500000000500015146653315016776 0ustar00philipphilip## Copyright (C) 2009 VZLU Prague, a.s., Czech Republic ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn{Function File} {@var{x} =} smwsolve (@var{a}, @var{u}, @var{v}, @var{b}) ## @deftypefnx{Function File} {} smwsolve (@var{solver}, @var{u}, @var{v}, @var{b}) ## Solves the square system @code{(A + U*V')*X == B}, where @var{u} and @var{v} are ## matrices with several columns, using the Sherman-Morrison-Woodbury formula, ## so that a system with @var{a} as left-hand side is actually solved. This is ## especially advantageous if @var{a} is diagonal, sparse, triangular or ## positive definite. ## @var{a} can be sparse or full, the other matrices are expected to be full. ## Instead of a matrix @var{a}, a user may alternatively provide a function ## @var{solver} that performs the left division operation. ## @end deftypefn ## Author: Jaroslav Hajek function x = smwsolve (a, u, v, b) if (nargin != 4) print_usage (); endif n = columns (u); if (n != columns (v) || rows (a) != rows (u) || columns (a) != rows (v)) error ("smwsolve: dimension mismatch"); elseif (! issquare (a)) error ("smwsolve: need a square matrix"); endif nc = columns (b); n = columns (u); if (ismatrix (a)) xx = a \ [b, u]; elseif (isa (a, "function_handle")) xx = a ([b, u]); if (rows (xx) != rows (a) || columns (xx) != (nc + n)) error ("smwsolve: invalid result from a solver function"); endif else error ("smwsolve: a must be a matrix or function handle"); endif x = xx(:,1:nc); y = xx(:,nc+1:nc+n); vxx = v' * xx; vx = vxx(:,1:nc); vy = vxx(:,nc+1:nc+n); x = x - y * ((eye (n) + vy) \ vx); endfunction %!test %! A = 2.1*eye (10); %! u = rand (10, 2); u /= diag (norm (u, "cols")); %! v = rand (10, 2); v /= diag (norm (v, "cols")); %! b = rand (10, 2); %! x1 = (A + u*v') \ b; %! x2 = smwsolve (A, u, v, b); %! assert (x1, x2, 1e-13); linear-algebra-2.2.4/inst/PaxHeaders/ndcovlt.m0000644000000000000000000000006215146653315016261 xustar0020 atime=1771787981 30 ctime=1771788142.227370642 linear-algebra-2.2.4/inst/ndcovlt.m0000644000175000017500000000566315146653315016607 0ustar00philipphilip## Copyright (C) 2010 VZLU Prague, a.s., Czech Republic ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn{Function File} {@var{y} =} ndcovlt (@var{x}, @var{t1}, @var{t2}, @dots{}) ## Computes an n-dimensional covariant linear transform of an n-d tensor, given a ## transformation matrix for each dimension. The number of columns of each transformation ## matrix must match the corresponding extent of @var{x}, and the number of rows determines ## the corresponding extent of @var{y}. For example: ## ## @example ## size (@var{x}, 2) == columns (@var{t2}) ## size (@var{y}, 2) == rows (@var{t2}) ## @end example ## ## The element @code{@var{y}(i1, i2, @dots{})} is defined as a sum of ## ## @example ## @var{x}(j1, j2, @dots{}) * @var{t1}(i1, j1) * @var{t2}(i2, j2) * @dots{} ## @end example ## ## over all j1, j2, @dots{}. For two dimensions, this reduces to ## @example ## @var{y} = @var{t1} * @var{x} * @var{t2}.' ## @end example ## ## [] passed as a transformation matrix is converted to identity matrix for ## the corresponding dimension. ## ## @end deftypefn ## Author: Jaroslav Hajek function y = ndcovlt (x, varargin) nd = max (ndims (x), nargin - 1); varargin = resize (varargin, 1, nd); # check dimensions for i = 1:nd ti = varargin{i}; if (isnumeric (ti) && ndims (ti) == 2) [r, c] = size (ti); if (r + c == 0) varargin{i} = eye (size (x, i)); elseif (c != size (x, i)) error ("ndcovt: dimension mismatch for x-th transformation matrix"); endif else error ("ndcovt: transformation matrices must be numeric 2d matrices"); endif endfor if (isempty (x)) szy = cellfun (@rows, varargin); y = zeros (szy); return endif ldp = [2:nd, 1]; ## First transformation. y = ldtrans (x, varargin{1}); ## Always shift one dimension. for i = 2:nd-1 y = ldtrans (permute (y, ldp), varargin{i}); endfor ## Permute to normal order now to save one permutation. if (nd > 2) y = ipermute (y, [nd-1:nd, 1:nd-2]); endif ## Now multiply from the right. szy = size (y); szy(end+1:nd-1) = 1; m = varargin{nd}; szy(nd) = rows (m); y = reshape (y, [], size (y, nd)); y = reshape (y * m.', szy); endfunction function y = ldtrans (x, m) sz = size (x); sz(1) = rows (m); y = reshape (m * x(:,:), sz); endfunction linear-algebra-2.2.4/inst/PaxHeaders/nmf_pg.m0000644000000000000000000000006215146653315016056 xustar0020 atime=1771787981 30 ctime=1771788142.227370642 linear-algebra-2.2.4/inst/nmf_pg.m0000644000175000017500000002106515146653315016376 0ustar00philipphilip## Copyright (C) 2005-2006 Chih-Jen Lin ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are met: ## ## 1 Redistributions of source code must retain the above copyright notice, ## this list of conditions and the following disclaimer. ## 2 Redistributions in binary form must reproduce the above copyright ## notice, this list of conditions and the following disclaimer in the ## documentation and/or other materials provided with the distribution. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ''AS IS'' ## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ## ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ## ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ## SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ## CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ## The views and conclusions contained in the software and documentation are ## those of the authors and should not be interpreted as representing official ## policies, either expressed or implied, of the copyright holders. ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{W}, @var{H}] =} nmf_pg (@var{V}, @var{Winit}, @ ## @var{Hinit}, @var{tol}, @var{timelimit}, @var{maxiter}) ## ## Non-negative matrix factorization by alternative non-negative least squares ## using projected gradients. ## ## The matrix @var{V} is factorized into two possitive matrices @var{W} and ## @var{H} such that @code{V = W*H + U}. Where @var{U} is a matrix of residuals ## that can be negative or positive. When the matrix @var{V} is positive the order ## of the elements in @var{U} is bounded by the optional named argument @var{tol} ## (default value @code{1e-9}). ## ## The factorization is not unique and depends on the inital guess for the matrices ## @var{W} and @var{H}. You can pass this initalizations using the optional ## named arguments @var{Winit} and @var{Hinit}. ## ## timelimit, maxiter: limit of time and iterations ## ## Examples: ## ## @example ## A = rand(10,5); ## [W H] = nmf_pg(A,tol=1e-3); ## U = W*H -A; ## disp(max(abs(U))); ## @end example ## ## @end deftypefn ## 2015 - Modified and adapted to Octave 4.0 by ## Juan Pablo Carbajal function [W, H] = nmf_pg (V, varargin) # JuanPi Fri 16 Mar 2012 10:49:11 AM CET # TODO: # - finish docstring # - avoid multiple transpositions # --- Parse arguments --- # isnummatrix = @(x) ismatrix (x) & isnumeric (x); parser = inputParser (); parser.FunctionName = "nmf_pg"; parser.addParamValue ('Winit', [], @ismatrix); parser.addParamValue ('Hinit', [], @ismatrix); parser.addParamValue ('Tol', 1e-6, @(x)x>0); parser.addParamValue ('TimeLimit', 10, @(x)x>0); parser.addParamValue ('MaxIter', 100, @(x)x>0); parser.addParamValue ('MaxSubIter', 1e3, @(x)x>0); parser.addParamValue ('Verbose', true); parser.parse(varargin{:}); Winit = parser.Results.Winit; Hinit = parser.Results.Hinit; tol = parser.Results.Tol; timelimit = parser.Results.TimeLimit; maxiter = parser.Results.MaxIter; maxsubiter = parser.Results.MaxSubIter; verbose = parser.Results.Verbose; # Check if text_waitbar is loaded __txtwb__ = true; if !exist ('text_waitbar') __txtwb__ = false; end clear parser # ------ # # --- Initialize matrices --- # [r c] = size (V); Hgiven = !isempty (Hinit); Wgiven = !isempty (Winit); if Wgiven && !Hgiven W = Winit; H = ones (size (W,2),c); elseif !Wgiven && Hgiven H = Hinit; W = ones (r, size(H,2)); elseif !Wgiven && !Hgiven if r == c W = ones (r) H = W else W = ones (r); H = ones (r,c); end else W = Winit; H = Hinit; end [Hr,Hc] = size(H); [Wr,Wc] = size(W); # start tracking time initt = cputime (); gradW = W*(H*H') - V*H'; gradH = (W'*W)*H - W'*V; initgrad = norm([gradW; gradH'],'fro'); # Tolerances for matrices tolW = max(0.001,tol)*initgrad; tolH = tolW; # ------ # # --- Main Loop --- # if verbose fprintf ('--- Factorizing %d-by-%d matrix into %d-by-%d times %d-by-%d\n',... r,c,Wr,Wc,Hr,Hc); fprintf ("Initial gradient norm = %f\n", initgrad); fflush (stdout); if __txtwb__ text_waitbar(0,'Please wait ...'); else printf ('Running main loop, this may take a while.\n'); fflush (stdout); end end for iter = 1:maxiter # stopping condition projnorm = norm ( [ gradW(gradW<0 | W>0); gradH(gradH<0 | H>0) ] ); stop_cond = [projnorm < tol*initgrad , cputime-initt > timelimit]; if any (stop_cond) if stop_cond(2) warning('mnf_pg:MaxIter',["Time limit exceeded.\n" ... "Could be solved increasing TimeLimit.\n"]); end break end # FIXME: avoid multiple transpositions [W, gradW, iterW] = nlssubprob(V', H', W', tolW, maxsubiter, verbose); W = W'; gradW = gradW'; if iterW == 1, tolW = 0.1 * tolW; end [H, gradH, iterH] = nlssubprob(V, W, H, tolH, maxsubiter, verbose); if iterH == 1, tolH = 0.1 * tolH; end if (iterW == 1 && iterH == 1 && tolH + tolW < tol*initgrad), warning ('nmf_pg:InvalidArgument','Failed to move'); break end if verbose && __txtwb__ text_waitbar (iter/maxiter); end end if iter == maxiter warning('mnf_pg:MaxIter',["Reached maximum iterations in main loop.\n" ... "Could be solved increasing MaxIter.\n"]); end if verbose fprintf ('\nIterations = %d\nFinal proj-grad norm = %f\n', iter, projnorm); fflush (stdout); end endfunction function [H, grad,iter] = nlssubprob(V,W,Hinit,tol,maxiter,verbose) % H, grad: output solution and gradient % iter: #iterations used % V, W: constant matrices % Hinit: initial solution % tol: stopping tolerance % maxiter: limit of iterations H = Hinit; WtV = W'*V; WtW = W'*W; alpha = 1; beta = 0.1; for iter=1:maxiter grad = WtW*H - WtV; projgrad = norm ( grad(grad < 0 | H >0) ); if projgrad < tol, break end % search step size Hn = max(H - alpha*grad, 0); d = Hn-H; gradd = sum ( sum (grad.*d) ); dQd = sum ( sum ((WtW*d).*d) ); if gradd + 0.5*dQd > 0.01*gradd, % decrease alpha while 1, alpha *= beta; Hn = max (H - alpha*grad, 0); d = Hn-H; gradd = sum (sum (grad.*d) ); dQd = sum (sum ((WtW*d).*d)); if gradd + 0.5*dQd <= 0.01*gradd || alpha < 1e-20 H = Hn; break end endwhile else % increase alpha while 1, Hp = Hn; alpha /= beta; Hn = max (H - alpha*grad, 0); d = Hn-H; gradd = sum ( sum (grad.*d) ); dQd = sum (sum ( (WtW*d).*d ) ); if gradd + 0.5*dQd > 0.01*gradd || Hn == Hp || alpha > 1e10 H = Hp; alpha *= beta; break end endwhile end endfor if iter == maxiter warning('mnf_pg:MaxIter',["Reached maximum iterations in nlssubprob\n" ... "Could be solved increasing MaxSubIter.\n"]); end endfunction %!demo %! t = linspace (0,1,100)'; %! %! ## --- Build hump functions of different frequency %! W_true = arrayfun ( @(f)sin(2*pi*f*t).^2, linspace (0.5,2,4), ... %! 'uniformoutput', false ); %! W_true = cell2mat (W_true); %! ## --- Build combinator vectors %! c = (1:4)'; %! H_true = arrayfun ( @(f)circshift(c,f), linspace (0,3,4), ... %! 'uniformoutput', false ); %! H_true = cell2mat (H_true); %! ## --- Mix them %! V = W_true*H_true; %! ## --- Give good inital guesses %! Winit = W_true + 0.4*randn(size(W_true)); %! Hinit = H_true + 0.2*randn(size(H_true)); %! ## --- Factorize %! [W H] = nmf_pg(V,'Winit',Winit,'Hinit',Hinit,'Tol',1e-6,'MaxIter',1e3); %! disp('True mixer') %! disp(H_true) %! disp('Rounded factorized mixer') %! disp(round(H)) %! ## --- Plot results %! plot(t,W,'o;factorized;') %! hold on %! plot(t,W_true,'-;True;') %! hold off %! axis tight linear-algebra-2.2.4/inst/PaxHeaders/ndmult.m0000644000000000000000000000006215146653315016113 xustar0020 atime=1771787981 30 ctime=1771788142.227370642 linear-algebra-2.2.4/inst/ndmult.m0000644000175000017500000001055315146653315016433 0ustar00philipphilip## Copyright (C) 2013 - Juan Pablo Carbajal ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## Author: Juan Pablo Carbajal ## -*- texinfo -*- ## @deftypefn {Function File} {@var{C} =} ndmult (@var{A},@var{B},@var{dim}) ## Multidimensional scalar product ## ## Given multidimensional arrays @var{A} and @var{B} with entries ## A(i1,12,@dots{},in) and B(j1,j2,@dots{},jm) and the 1-by-2 dimesion array @var{dim} ## with entries [N,K]. Assume that ## ## @example ## shape(@var{A},N) == shape(@var{B},K) ## @end example ## ## Then the function calculates the product ## ## @example ## @group ## ## C (i1,@dots{},iN-1,iN+1,@dots{},in,j1,@dots{},jK-1,jK+1,@dots{},jm) = ## = sum_over_s A(i1,@dots{},iN-1,s,iN+1,@dots{},in)*B(j1,@dots{},jK-1,s,jK+1,@dots{},jm) ## ## @end group ## @end example ## ## For example if @command{size(@var{A}) == [2,3,4]} and @command{size(@var{B}) == [5,3]} ## then the @command{@var{C} = ndmult(A,B,[2,2])} produces @command{size(@var{C}) == [2,4,5]}. ## ## This function is useful, for example, when calculating grammian matrices of a set of signals ## produced from different experiments. ## @example ## nT = 100; ## t = 2 * pi * linspace (0,1,nT).'; ## signals = zeros (nT,3,2); % 2 experiments measuring 3 signals at nT timestamps ## ## signals(:,:,1) = [sin(2*t) cos(2*t) sin(4*t).^2]; ## signals(:,:,2) = [sin(2*t+pi/4) cos(2*t+pi/4) sin(4*t+pi/6).^2]; ## ## sT(:,:,1) = signals(:,:,1).'; ## sT(:,:,2) = signals(:,:,2).'; ## G = ndmult (signals, sT, [1 2]); ## ## @end example ## In the example G contains the scalar product of all the signals against each other. ## This can be verified in the following way: ## @example ## s1 = 1 e1 = 1; % First signal in first experiment; ## s2 = 1 e2 = 2; % First signal in second experiment; ## [G(s1,e1,s2,e2) signals(:,s1,e1)'*signals(:,s2,e2)] ## @end example ## You may want to re-order the scalar products into a 2-by-2 arrangement (representing pairs of experiments) ## of gramian matrices. The following command @command{G = permute(G,[1 3 2 4])} does it. ## ## @end deftypefn function M = ndmult (A,B,dim) dA = dim(1); dB = dim(2); sA = size (A); nA = length (sA); perA = [1:(dA-1) (dA+1):(nA-1) nA dA](1:nA); Ap = permute (A, perA); Ap = reshape (Ap, prod (sA(perA(1:end-1))), sA(perA(end))); sB = size (B); nB = length (sB); perB = [dB 1:(dB-1) (dB+1):(nB-1) nB](1:nB); Bp = permute (B, perB); Bp = reshape (Bp, sB(perB(1)), prod (sB(perB(2:end)))); M = Ap * Bp; s = [sA(perA(1:end-1)) sB(perB(2:end))]; M = squeeze (reshape (M, s)); endfunction %!demo %! A =@(l)[1 l; 0 1]; %! N = 5; %! p = linspace (-1,1,N); %! T = zeros (2,2,N); %! # A book of x-shears, one transformation per page. %! for i=1:N %! T(:,:,i) = A(p(i)); %! endfor %! %! # The unit square %! P = [0 0; 1 0; 1 1; 0 1]; %! %! C = ndmult (T,P,[2 2]); %! # Re-order to get a book of polygons %! C = permute (C,[3 1 2]); %! %! try %! pkg load geometry %! do_plot = true; %! catch %! printf ("Geometry package needed to plot this demo\n."); %! do_plot = false; %! end %! if do_plot %! clf %! drawPolygon (P,"k","linewidth",2); %! hold on %! c = jet(N); %! for i=1:N %! drawPolygon (C(:,:,i),":","color",c(i,:),"linewidth",2); %! endfor %! axis equal %! set(gca,"visible","off"); %! hold off %! endif %! %! # ------------------------------------------------- %! # The handler A describes a parametrized planar geometrical %! # transformation (shear in the x-direction). %! # Choosing N values of the parameter we obtain a 2x2xN matrix. %! # We can apply all these transformations to the poligon defined %! # by matrix P in one operation. %! # The poligon resulting from the i-th parameter value is stored %! # in C(:,:,i). %! # You can plot them using the geometry package. linear-algebra-2.2.4/inst/PaxHeaders/circulant_eig.m0000644000000000000000000000006215146653315017420 xustar0020 atime=1771787981 30 ctime=1771788142.227370642 linear-algebra-2.2.4/inst/circulant_eig.m0000644000175000017500000000474015146653315017741 0ustar00philipphilip## Copyright (C) 2012 Nir Krakauer ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn{Function File} {@var{lambda} =} circulant_eig (@var{v}) ## @deftypefnx{Function File} {[@var{vs}, @var{lambda}] =} circulant_eig (@var{v}) ## ## Fast, compact calculation of eigenvalues and eigenvectors of a circulant matrix@* ## Given an @var{n}*1 vector @var{v}, return the eigenvalues @var{lambda} and optionally eigenvectors @var{vs} of the @var{n}*@var{n} circulant matrix @var{C} that has @var{v} as its first column ## ## Theoretically same as @code{eig(make_circulant_matrix(v))}, but many fewer computations; does not form @var{C} explicitly ## ## Reference: Robert M. Gray, Toeplitz and Circulant Matrices: A Review, Now Publishers, http://ee.stanford.edu/~gray/toeplitz.pdf, Chapter 3 ## ## @seealso{gallery, circulant_matrix_vector_product, circulant_inv} ## @end deftypefn function [a, b] = circulant_eig (v) ## FIXME when warning for broadcastin is turned off by default, this ## unwind_protect block could be removed ## we are using broadcasting on the code below so we turn off the ## warnings but will restore to previous state at the end bc_warn = warning ("query", "Octave:broadcast"); unwind_protect warning ("off", "Octave:broadcast"); #find the eigenvalues n = numel(v); lambda = ones(n, 1); s = (0:(n-1)); lambda = sum(v .* exp(-2*pi*i*s'*s/n))'; if nargout < 2 a = lambda; return endif #find the eigenvectors (which in fact do not depend on v) a = exp(-2*i*pi*s'*s/n) / sqrt(n); b = diag(lambda); unwind_protect_cleanup ## restore broadcats warning status warning (bc_warn.state, "Octave:broadcast"); end_unwind_protect endfunction %!shared v,C,vs,lambda %! v = [1 2 3]'; %! C = gallery("circul", v)'; %! [vs lambda] = circulant_eig(v); %!assert (vs*lambda, C*vs, 100*eps); linear-algebra-2.2.4/inst/PaxHeaders/lobpcg.m0000644000000000000000000000006215146653315016056 xustar0020 atime=1771787981 30 ctime=1771788142.227370642 linear-algebra-2.2.4/inst/lobpcg.m0000644000175000017500000012052715146653315016401 0ustar00philipphilip## Copyright (C) 2000-2011 A.V. Knyazev ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU Lesser General Public License as published by the Free ## Software Foundation; either version 3 of the License, or (at your option) any ## later version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License ## for more details. ## ## You should have received a copy of the GNU Lesser General Public License ## along with this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{blockVectorX}, @var{lambda}] =} lobpcg (@var{blockVectorX}, @var{operatorA}) ## @deftypefnx {Function File} {[@var{blockVectorX}, @var{lambda}, @var{failureFlag}] =} lobpcg (@var{blockVectorX}, @var{operatorA}) ## @deftypefnx {Function File} {[@var{blockVectorX}, @var{lambda}, @var{failureFlag}, @var{lambdaHistory}, @var{residualNormsHistory}] =} lobpcg (@var{blockVectorX}, @var{operatorA}, @var{operatorB}, @var{operatorT}, @var{blockVectorY}, @var{residualTolerance}, @var{maxIterations}, @var{verbosityLevel}) ## Solves Hermitian partial eigenproblems using preconditioning. ## ## The first form outputs the array of algebraic smallest eigenvalues @var{lambda} and ## corresponding matrix of orthonormalized eigenvectors @var{blockVectorX} of the ## Hermitian (full or sparse) operator @var{operatorA} using input matrix ## @var{blockVectorX} as an initial guess, without preconditioning, somewhat ## similar to: ## ## @example ## # for real symmetric operator operatorA ## opts.issym = 1; opts.isreal = 1; K = size (blockVectorX, 2); ## [blockVectorX, lambda] = eigs (operatorA, K, 'SR', opts); ## ## # for Hermitian operator operatorA ## K = size (blockVectorX, 2); ## [blockVectorX, lambda] = eigs (operatorA, K, 'SR'); ## @end example ## ## The second form returns a convergence flag. If @var{failureFlag} is 0 then ## all the eigenvalues converged; otherwise not all converged. ## ## The third form computes smallest eigenvalues @var{lambda} and corresponding eigenvectors ## @var{blockVectorX} of the generalized eigenproblem Ax=lambda Bx, where ## Hermitian operators @var{operatorA} and @var{operatorB} are given as functions, as ## well as a preconditioner, @var{operatorT}. The operators @var{operatorB} and ## @var{operatorT} must be in addition @emph{positive definite}. To compute the largest ## eigenpairs of @var{operatorA}, simply apply the code to @var{operatorA} multiplied by ## -1. The code does not involve @emph{any} matrix factorizations of @var{operatorA} and ## @var{operatorB}, thus, e.g., it preserves the sparsity and the structure of ## @var{operatorA} and @var{operatorB}. ## ## @var{residualTolerance} and @var{maxIterations} control tolerance and max number of ## steps, and @var{verbosityLevel} = 0, 1, or 2 controls the amount of printed ## info. @var{lambdaHistory} is a matrix with all iterative lambdas, and ## @var{residualNormsHistory} are matrices of the history of 2-norms of residuals ## ## Required input: ## @itemize @bullet ## @item ## @var{blockVectorX} (class numeric) - initial approximation to eigenvectors, ## full or sparse matrix n-by-blockSize. @var{blockVectorX} must be full rank. ## @item ## @var{operatorA} (class numeric, char, or function_handle) - the main operator ## of the eigenproblem, can be a matrix, a function name, or handle ## @end itemize ## ## Optional function input: ## @itemize @bullet ## @item ## @var{operatorB} (class numeric, char, or function_handle) - the second operator, ## if solving a generalized eigenproblem, can be a matrix, a function name, or ## handle; by default if empty, @code{operatorB = I}. ## @item ## @var{operatorT} (class char or function_handle) - the preconditioner, by ## default @code{operatorT(blockVectorX) = blockVectorX}. ## @end itemize ## ## Optional constraints input: ## @itemize @bullet ## @item ## @var{blockVectorY} (class numeric) - a full or sparse n-by-sizeY matrix of ## constraints, where sizeY < n. @var{blockVectorY} must be full rank. The ## iterations will be performed in the (operatorB-) orthogonal complement of the ## column-space of @var{blockVectorY}. ## @end itemize ## ## Optional scalar input parameters: ## @itemize @bullet ## @item ## @var{residualTolerance} (class numeric) - tolerance, by default, @code{residualTolerance = n * sqrt (eps)} ## @item ## @var{maxIterations} - max number of iterations, by default, @code{maxIterations = min (n, 20)} ## @item ## @var{verbosityLevel} - either 0 (no info), 1, or 2 (with pictures); by ## default, @code{verbosityLevel = 0}. ## @end itemize ## ## Required output: ## @itemize @bullet ## @item ## @var{blockVectorX} and @var{lambda} (class numeric) both are computed ## blockSize eigenpairs, where @code{blockSize = size (blockVectorX, 2)} ## for the initial guess @var{blockVectorX} if it is full rank. ## @end itemize ## ## Optional output: ## @itemize @bullet ## @item ## @var{failureFlag} (class integer) as described above. ## @item ## @var{lambdaHistory} (class numeric) as described above. ## @item ## @var{residualNormsHistory} (class numeric) as described above. ## @end itemize ## ## Functions @code{operatorA(blockVectorX)}, @code{operatorB(blockVectorX)} and ## @code{operatorT(blockVectorX)} must support @var{blockVectorX} being a matrix, not ## just a column vector. ## ## Every iteration involves one application of @var{operatorA} and @var{operatorB}, and ## one of @var{operatorT}. ## ## Main memory requirements: 6 (9 if @code{isempty(operatorB)=0}) matrices of the ## same size as @var{blockVectorX}, 2 matrices of the same size as @var{blockVectorY} ## (if present), and two square matrices of the size 3*blockSize. ## ## In all examples below, we use the Laplacian operator in a 20x20 square ## with the mesh size 1 which can be generated in MATLAB by running: ## @example ## A = delsq (numgrid ('S', 21)); ## n = size (A, 1); ## @end example ## ## or in MATLAB and Octave by: ## @example ## [~,~,A] = laplacian ([19, 19]); ## n = size (A, 1); ## @end example ## ## Note that @code{laplacian} is a function of the specfun octave-forge package. ## ## The following Example: ## @example ## [blockVectorX, lambda, failureFlag] = lobpcg (randn (n, 8), A, 1e-5, 50, 2); ## @end example ## ## attempts to compute 8 first eigenpairs without preconditioning, but not all ## eigenpairs converge after 50 steps, so failureFlag=1. ## ## The next Example: ## @example ## blockVectorY = []; ## lambda_all = []; ## for j = 1:4 ## [blockVectorX, lambda] = lobpcg (randn (n, 2), A, blockVectorY, 1e-5, 200, 2); ## blockVectorY = [blockVectorY, blockVectorX]; ## lambda_all = [lambda_all' lambda']'; ## pause; ## end ## @end example ## ## attemps to compute the same 8 eigenpairs by calling the code 4 times with ## blockSize=2 using orthogonalization to the previously founded eigenvectors. ## ## The following Example: ## @example ## R = ichol (A, struct('michol', 'on')); ## precfun = @@(x)R\(R'\x); ## [blockVectorX, lambda, failureFlag] = lobpcg (randn (n, 8), A, [], @@(x)precfun(x), 1e-5, 60, 2); ## @end example ## ## computes the same eigenpairs in less then 25 steps, so that failureFlag=0 ## using the preconditioner function @code{precfun}, defined inline. If @code{precfun} ## is defined as an octave function in a file, the function handle ## @code{@@(x)precfun(x)} can be equivalently replaced by the function name @code{precfun}. Running: ## ## @example ## [blockVectorX, lambda, failureFlag] = lobpcg (randn (n, 8), A, speye (n), @@(x)precfun(x), 1e-5, 50, 2); ## @end example ## ## produces similar answers, but is somewhat slower and needs more memory as ## technically a generalized eigenproblem with B=I is solved here. ## ## The following example for a mostly diagonally dominant sparse matrix A ## demonstrates different types of preconditioning, compared to the standard ## use of the main diagonal of A: ## ## @example ## clear all; close all; ## n = 1000; ## M = spdiags ([1:n]', 0, n, n); ## precfun = @@(x)M\x; ## A = M + sprandsym (n, .1); ## Xini = randn (n, 5); ## maxiter = 15; ## tol = 1e-5; ## [~,~,~,~,rnp] = lobpcg (Xini, A, tol, maxiter, 1); ## [~,~,~,~,r] = lobpcg (Xini, A, [], @@(x)precfun(x), tol, maxiter, 1); ## subplot (2,2,1), semilogy (r'); hold on; ## semilogy (rnp', ':>'); ## title ('No preconditioning (top)'); axis tight; ## M(1,2) = 2; ## precfun = @@(x)M\x; % M is no longer symmetric ## [~,~,~,~,rns] = lobpcg (Xini, A, [], @@(x)precfun(x), tol, maxiter, 1); ## subplot (2,2,2), semilogy (r'); hold on; ## semilogy (rns', '--s'); ## title ('Nonsymmetric preconditioning (square)'); axis tight; ## M(1,2) = 0; ## precfun = @@(x)M\(x+10*sin(x)); % nonlinear preconditioning ## [~,~,~,~,rnl] = lobpcg (Xini, A, [], @@(x)precfun(x), tol, maxiter, 1); ## subplot (2,2,3), semilogy (r'); hold on; ## semilogy (rnl', '-.*'); ## title ('Nonlinear preconditioning (star)'); axis tight; ## M = abs (M - 3.5 * speye (n, n)); ## precfun = @@(x)M\x; ## [~,~,~,~,rs] = lobpcg (Xini, A, [], @@(x)precfun(x), tol, maxiter, 1); ## subplot (2,2,4), semilogy (r'); hold on; ## semilogy (rs', '-d'); ## title ('Selective preconditioning (diamond)'); axis tight; ## @end example ## ## @heading References ## This main function @code{lobpcg} is a version of the preconditioned conjugate ## gradient method (Algorithm 5.1) described in A. V. Knyazev, Toward the Optimal ## Preconditioned Eigensolver: ## Locally Optimal Block Preconditioned Conjugate Gradient Method, ## SIAM Journal on Scientific Computing 23 (2001), no. 2, pp. 517-541. ## @uref{http://dx.doi.org/10.1137/S1064827500366124} ## ## @heading Known bugs/features ## @itemize @bullet ## @item ## an excessively small requested tolerance may result in often restarts and ## instability. The code is not written to produce an eps-level accuracy! Use ## common sense. ## @item ## the code may be very sensitive to the number of eigenpairs computed, ## if there is a cluster of eigenvalues not completely included, cf. ## @example ## operatorA = diag ([1 1.99 2:99]); ## [blockVectorX, lambda] = lobpcg (randn (100, 1),operatorA, 1e-10, 80, 2); ## [blockVectorX, lambda] = lobpcg (randn (100, 2),operatorA, 1e-10, 80, 2); ## [blockVectorX, lambda] = lobpcg (randn (100, 3),operatorA, 1e-10, 80, 2); ## @end example ## @end itemize ## ## @heading Distribution ## The main distribution site: @uref{http://math.ucdenver.edu/~aknyazev/} ## ## A C-version of this code is a part of the @uref{http://code.google.com/p/blopex/} ## package and is directly available, e.g., in PETSc and HYPRE. ## @end deftypefn function [blockVectorX,lambda,varargout] = lobpcg(blockVectorX,operatorA,varargin) %Begin % constants CONVENTIONAL_CONSTRAINTS = 1; SYMMETRIC_CONSTRAINTS = 2; %Initial settings failureFlag = 1; if nargin < 2 error('BLOPEX:lobpcg:NotEnoughInputs',... strcat('There must be at least 2 input agruments: ',... 'blockVectorX and operatorA')); end if nargin > 8 warning('BLOPEX:lobpcg:TooManyInputs',... strcat('There must be at most 8 input agruments ',... 'unless arguments are passed to a function')); end if ~isnumeric(blockVectorX) error('BLOPEX:lobpcg:FirstInputNotNumeric',... 'The first input argument blockVectorX must be numeric'); end [n,blockSize]=size(blockVectorX); if blockSize > n error('BLOPEX:lobpcg:FirstInputFat',... 'The first input argument blockVectorX must be tall, not fat'); end if n < 6 error('BLOPEX:lobpcg:MatrixTooSmall',... 'The code does not work for matrices of small sizes'); end if isa(operatorA,'numeric') nA = size(operatorA,1); if any(size(operatorA) ~= nA) error('BLOPEX:lobpcg:MatrixNotSquare',... 'operatorA must be a square matrix or a string'); end if size(operatorA) ~= n error('BLOPEX:lobpcg:MatrixWrongSize',... ['The size ' int2str(size(operatorA))... ' of operatorA is not the same as ' int2str(n)... ' - the number of rows of blockVectorX']); end end count_string = 0; operatorT = []; operatorB = []; residualTolerance = []; maxIterations = []; verbosityLevel = []; blockVectorY = []; sizeY = 0; for j = 1:nargin-2 if isequal(size(varargin{j}),[n,n]) if isempty(operatorB) operatorB = varargin{j}; else error('BLOPEX:lobpcg:TooManyMatrixInputs',... strcat('Too many matrix input arguments. ',... 'Preconditioner operatorT must be an M-function')); end elseif isequal(size(varargin{j},1),n) && size(varargin{j},2) < n if isempty(blockVectorY) blockVectorY = varargin{j}; sizeY=size(blockVectorY,2); else error('BLOPEX:lobpcg:WrongConstraintsFormat',... 'Something wrong with blockVectorY input argument'); end elseif ischar(varargin{j}) || isa(varargin{j},'function_handle') if count_string == 0 if isempty(operatorB) operatorB = varargin{j}; count_string = count_string + 1; else operatorT = varargin{j}; end elseif count_string == 1 operatorT = varargin{j}; else warning('BLOPEX:lobpcg:TooManyStringFunctionHandleInputs',... 'Too many string or FunctionHandle input arguments'); end elseif isequal(size(varargin{j}),[n,n]) error('BLOPEX:lobpcg:WrongPreconditionerFormat',... 'Preconditioner operatorT must be an M-function'); elseif max(size(varargin{j})) == 1 if isempty(residualTolerance) residualTolerance = varargin{j}; elseif isempty(maxIterations) maxIterations = varargin{j}; elseif isempty(verbosityLevel) verbosityLevel = varargin{j}; else warning('BLOPEX:lobpcg:TooManyScalarInputs',... 'Too many scalar parameters, need only three'); end elseif isempty(varargin{j}) if isempty(operatorB) count_string = count_string + 1; elseif ~isempty(operatorT) count_string = count_string + 1; elseif ~isempty(blockVectorY) error('BLOPEX:lobpcg:UnrecognizedEmptyInput',... ['Unrecognized empty input argument number ' int2str(j+2)]); end else error('BLOPEX:lobpcg:UnrecognizedInput',... ['Input argument number ' int2str(j+2) ' not recognized.']); end end if verbosityLevel if issparse(blockVectorX) fprintf(['The sparse initial guess with %i colunms '... 'and %i raws is detected \n'],n,blockSize); else fprintf(['The full initial guess with %i colunms '... 'and %i raws is detected \n'],n,blockSize); end if ischar(operatorA) fprintf('The main operator is detected as an M-function %s \n',... operatorA); elseif isa(operatorA,'function_handle') fprintf('The main operator is detected as an M-function %s \n',... func2str(operatorA)); elseif issparse(operatorA) fprintf('The main operator is detected as a sparse matrix \n'); else fprintf('The main operator is detected as a full matrix \n'); end if isempty(operatorB) fprintf('Solving standard eigenvalue problem, not generalized \n'); elseif ischar(operatorB) fprintf(['The second operator of the generalized eigenproblem \n'... 'is detected as an M-function %s \n'],operatorB); elseif isa(operatorB,'function_handle') fprintf(['The second operator of the generalized eigenproblem \n'... 'is detected as an M-function %s \n'],func2str(operatorB)); elseif issparse(operatorB) fprintf(strcat('The second operator of the generalized',... 'eigenproblem \n is detected as a sparse matrix \n')); else fprintf(strcat('The second operator of the generalized',... 'eigenproblem \n is detected as a full matrix \n')); end if isempty(operatorT) fprintf('No preconditioner is detected \n'); elseif ischar(operatorT) fprintf('The preconditioner is detected as an M-function %s \n',... operatorT); elseif isa(operatorT,'function_handle') fprintf('The preconditioner is detected as an M-function %s \n',... func2str(operatorT)); end if isempty(blockVectorY) fprintf('No matrix of constraints is detected \n') elseif issparse(blockVectorY) fprintf('The sparse matrix of %i constraints is detected \n',sizeY); else fprintf('The full matrix of %i constraints is detected \n',sizeY); end if issparse(blockVectorY) ~= issparse(blockVectorX) warning('BLOPEX:lobpcg:SparsityInconsistent',... strcat('The sparsity formats of the initial guess and ',... 'the constraints are inconsistent')); end end % Set defaults if isempty(residualTolerance) residualTolerance = sqrt(eps)*n; end if isempty(maxIterations) maxIterations = min(n,20); end if isempty(verbosityLevel) verbosityLevel = 0; end if verbosityLevel fprintf('Tolerance %e and maximum number of iterations %i \n',... residualTolerance,maxIterations) end %constraints preprocessing if isempty(blockVectorY) constraintStyle = 0; else % constraintStyle = SYMMETRIC_CONSTRAINTS; % more accurate? constraintStyle = CONVENTIONAL_CONSTRAINTS; end if constraintStyle == CONVENTIONAL_CONSTRAINTS if isempty(operatorB) gramY = blockVectorY'*blockVectorY; else if isnumeric(operatorB) blockVectorBY = operatorB*blockVectorY; else blockVectorBY = feval(operatorB,blockVectorY); end gramY=blockVectorY'*blockVectorBY; end gramY=(gramY'+gramY)*0.5; if isempty(operatorB) blockVectorX = blockVectorX - ... blockVectorY*(gramY\(blockVectorY'*blockVectorX)); else blockVectorX =blockVectorX - ... blockVectorY*(gramY\(blockVectorBY'*blockVectorX)); end elseif constraintStyle == SYMMETRIC_CONSTRAINTS if ~isempty(operatorB) if isnumeric(operatorB) blockVectorY = operatorB*blockVectorY; else blockVectorY = feval(operatorB,blockVectorY); end end if isempty(operatorT) gramY = blockVectorY'*blockVectorY; else blockVectorTY = feval(operatorT,blockVectorY); gramY = blockVectorY'*blockVectorTY; end gramY=(gramY'+gramY)*0.5; if isempty(operatorT) blockVectorX = blockVectorX - ... blockVectorY*(gramY\(blockVectorY'*blockVectorX)); else blockVectorX = blockVectorX - ... blockVectorTY*(gramY\(blockVectorY'*blockVectorX)); end end %Making the initial vectors (operatorB-) orthonormal if isempty(operatorB) %[blockVectorX,gramXBX] = qr(blockVectorX,0); gramXBX=blockVectorX'*blockVectorX; if ~isreal(gramXBX) gramXBX=(gramXBX+gramXBX')*0.5; end [gramXBX,cholFlag]=chol(gramXBX); if cholFlag ~= 0 error('BLOPEX:lobpcg:ConstraintsTooTight',... 'The initial approximation after constraints is not full rank'); end blockVectorX = blockVectorX/gramXBX; else %[blockVectorX,blockVectorBX] = orth(operatorB,blockVectorX); if isnumeric(operatorB) blockVectorBX = operatorB*blockVectorX; else blockVectorBX = feval(operatorB,blockVectorX); end gramXBX=blockVectorX'*blockVectorBX; if ~isreal(gramXBX) gramXBX=(gramXBX+gramXBX')*0.5; end [gramXBX,cholFlag]=chol(gramXBX); if cholFlag ~= 0 error('BLOPEX:lobpcg:InitialNotFullRank',... sprintf('%s\n%s', ... 'The initial approximation after constraints is not full rank',... 'or/and operatorB is not positive definite')); end blockVectorX = blockVectorX/gramXBX; blockVectorBX = blockVectorBX/gramXBX; end % Checking if the problem is big enough for the algorithm, % i.e. n-sizeY > 5*blockSize % Theoretically, the algorithm should be able to run if % n-sizeY > 3*blockSize, % but the extreme cases might be unstable, so we use 5 instead of 3 here. if n-sizeY < 5*blockSize error('BLOPEX:lobpcg:MatrixTooSmall','%s\n%s', ... 'The problem size is too small, relative to the block size.',... 'Try using eig() or eigs() instead.'); end % Preallocation residualNormsHistory=zeros(blockSize,maxIterations); lambdaHistory=zeros(blockSize,maxIterations+1); condestGhistory=zeros(1,maxIterations+1); blockVectorBR=zeros(n,blockSize); blockVectorAR=zeros(n,blockSize); blockVectorP=zeros(n,blockSize); blockVectorAP=zeros(n,blockSize); blockVectorBP=zeros(n,blockSize); %Initial settings for the loop if isnumeric(operatorA) blockVectorAX = operatorA*blockVectorX; else blockVectorAX = feval(operatorA,blockVectorX); end gramXAX = full(blockVectorX'*blockVectorAX); gramXAX = (gramXAX + gramXAX')*0.5; % eig(...,'chol') uses only the diagonal and upper triangle - % not true in MATLAB % Octave v3.2.3-4, eig() does not support inputting 'chol' [coordX,gramXAX]=eig(gramXAX,eye(blockSize)); lambda=diag(gramXAX); %eig returns non-ordered eigenvalues on the diagonal if issparse(blockVectorX) coordX=sparse(coordX); end blockVectorX = blockVectorX*coordX; blockVectorAX = blockVectorAX*coordX; if ~isempty(operatorB) blockVectorBX = blockVectorBX*coordX; end clear coordX condestGhistory(1)=-log10(eps)/2; %if too small cause unnecessary restarts lambdaHistory(1:blockSize,1)=lambda; activeMask = true(blockSize,1); % currentBlockSize = blockSize; %iterate all % % restart=1;%steepest descent %The main part of the method is the loop of the CG method: begin for iterationNumber=1:maxIterations % %Computing the active residuals % if isempty(operatorB) % if currentBlockSize > 1 % blockVectorR(:,activeMask)=blockVectorAX(:,activeMask) - ... % blockVectorX(:,activeMask)*spdiags(lambda(activeMask),0,currentBlockSize,currentBlockSize); % else % blockVectorR(:,activeMask)=blockVectorAX(:,activeMask) - ... % blockVectorX(:,activeMask)*lambda(activeMask); % %to make blockVectorR full when lambda is just a scalar % end % else % if currentBlockSize > 1 % blockVectorR(:,activeMask)=blockVectorAX(:,activeMask) - ... % blockVectorBX(:,activeMask)*spdiags(lambda(activeMask),0,currentBlockSize,currentBlockSize); % else % blockVectorR(:,activeMask)=blockVectorAX(:,activeMask) - ... % blockVectorBX(:,activeMask)*lambda(activeMask); % %to make blockVectorR full when lambda is just a scalar % end % end %Computing all residuals if isempty(operatorB) if blockSize > 1 blockVectorR = blockVectorAX - ... blockVectorX*spdiags(lambda,0,blockSize,blockSize); else blockVectorR = blockVectorAX - blockVectorX*lambda; %to make blockVectorR full when lambda is just a scalar end else if blockSize > 1 blockVectorR=blockVectorAX - ... blockVectorBX*spdiags(lambda,0,blockSize,blockSize); else blockVectorR = blockVectorAX - blockVectorBX*lambda; %to make blockVectorR full when lambda is just a scalar end end %Satisfying the constraints for the active residulas if constraintStyle == SYMMETRIC_CONSTRAINTS if isempty(operatorT) blockVectorR(:,activeMask) = blockVectorR(:,activeMask) - ... blockVectorY*(gramY\(blockVectorY'*... blockVectorR(:,activeMask))); else blockVectorR(:,activeMask) = blockVectorR(:,activeMask) - ... blockVectorY*(gramY\(blockVectorTY'*... blockVectorR(:,activeMask))); end end residualNorms=full(sqrt(sum(conj(blockVectorR).*blockVectorR)')); residualNormsHistory(1:blockSize,iterationNumber)=residualNorms; %index antifreeze activeMask = full(residualNorms > residualTolerance) & activeMask; %activeMask = full(residualNorms > residualTolerance); %above allows vectors back into active, which causes problems with frosen Ps %activeMask = full(residualNorms > 0); %iterate all, ignore freeze currentBlockSize = sum(activeMask); if currentBlockSize == 0 failureFlag=0; %all eigenpairs converged break end %Applying the preconditioner operatorT to the active residulas if ~isempty(operatorT) blockVectorR(:,activeMask) = ... feval(operatorT,blockVectorR(:,activeMask)); end if constraintStyle == CONVENTIONAL_CONSTRAINTS if isempty(operatorB) blockVectorR(:,activeMask) = blockVectorR(:,activeMask) - ... blockVectorY*(gramY\(blockVectorY'*... blockVectorR(:,activeMask))); else blockVectorR(:,activeMask) = blockVectorR(:,activeMask) - ... blockVectorY*(gramY\(blockVectorBY'*... blockVectorR(:,activeMask))); end end %Making active (preconditioned) residuals orthogonal to blockVectorX if isempty(operatorB) blockVectorR(:,activeMask) = blockVectorR(:,activeMask) - ... blockVectorX*(blockVectorX'*blockVectorR(:,activeMask)); else blockVectorR(:,activeMask) = blockVectorR(:,activeMask) - ... blockVectorX*(blockVectorBX'*blockVectorR(:,activeMask)); end %Making active residuals orthonormal if isempty(operatorB) %[blockVectorR(:,activeMask),gramRBR]=... %qr(blockVectorR(:,activeMask),0); %to increase stability gramRBR=blockVectorR(:,activeMask)'*blockVectorR(:,activeMask); if ~isreal(gramRBR) gramRBR=(gramRBR+gramRBR')*0.5; end [gramRBR,cholFlag]=chol(gramRBR); if cholFlag == 0 blockVectorR(:,activeMask) = blockVectorR(:,activeMask)/gramRBR; else warning('BLOPEX:lobpcg:ResidualNotFullRank',... 'The residual is not full rank.'); break end else if isnumeric(operatorB) blockVectorBR(:,activeMask) = ... operatorB*blockVectorR(:,activeMask); else blockVectorBR(:,activeMask) = ... feval(operatorB,blockVectorR(:,activeMask)); end gramRBR=blockVectorR(:,activeMask)'*blockVectorBR(:,activeMask); if ~isreal(gramRBR) gramRBR=(gramRBR+gramRBR')*0.5; end [gramRBR,cholFlag]=chol(gramRBR); if cholFlag == 0 blockVectorR(:,activeMask) = ... blockVectorR(:,activeMask)/gramRBR; blockVectorBR(:,activeMask) = ... blockVectorBR(:,activeMask)/gramRBR; else warning('BLOPEX:lobpcg:ResidualNotFullRankOrElse',... strcat('The residual is not full rank or/and operatorB ',... 'is not positive definite.')); break end end clear gramRBR; if isnumeric(operatorA) blockVectorAR(:,activeMask) = operatorA*blockVectorR(:,activeMask); else blockVectorAR(:,activeMask) = ... feval(operatorA,blockVectorR(:,activeMask)); end if iterationNumber > 1 %Making active conjugate directions orthonormal if isempty(operatorB) %[blockVectorP(:,activeMask),gramPBP] = qr(blockVectorP(:,activeMask),0); gramPBP=blockVectorP(:,activeMask)'*blockVectorP(:,activeMask); if ~isreal(gramPBP) gramPBP=(gramPBP+gramPBP')*0.5; end [gramPBP,cholFlag]=chol(gramPBP); if cholFlag == 0 blockVectorP(:,activeMask) = ... blockVectorP(:,activeMask)/gramPBP; blockVectorAP(:,activeMask) = ... blockVectorAP(:,activeMask)/gramPBP; else warning('BLOPEX:lobpcg:DirectionNotFullRank',... 'The direction matrix is not full rank.'); break end else gramPBP=blockVectorP(:,activeMask)'*blockVectorBP(:,activeMask); if ~isreal(gramPBP) gramPBP=(gramPBP+gramPBP')*0.5; end [gramPBP,cholFlag]=chol(gramPBP); if cholFlag == 0 blockVectorP(:,activeMask) = ... blockVectorP(:,activeMask)/gramPBP; blockVectorAP(:,activeMask) = ... blockVectorAP(:,activeMask)/gramPBP; blockVectorBP(:,activeMask) = ... blockVectorBP(:,activeMask)/gramPBP; else warning('BLOPEX:lobpcg:DirectionNotFullRank',... strcat('The direction matrix is not full rank ',... 'or/and operatorB is not positive definite.')); break end end clear gramPBP end condestGmean = mean(condestGhistory(max(1,iterationNumber-10-... round(log(currentBlockSize))):iterationNumber)); % restart=1; % The Raileight-Ritz method for [blockVectorX blockVectorR blockVectorP] if residualNorms > eps^0.6 explicitGramFlag = 0; else explicitGramFlag = 1; %suggested by Garrett Moran, private end activeRSize=size(blockVectorR(:,activeMask),2); if iterationNumber == 1 activePSize=0; restart=1; else activePSize=size(blockVectorP(:,activeMask),2); restart=0; end gramXAR=full(blockVectorAX'*blockVectorR(:,activeMask)); gramRAR=full(blockVectorAR(:,activeMask)'*blockVectorR(:,activeMask)); gramRAR=(gramRAR'+gramRAR)*0.5; if explicitGramFlag gramXAX=full(blockVectorAX'*blockVectorX); gramXAX=(gramXAX'+gramXAX)*0.5; if isempty(operatorB) gramXBX=full(blockVectorX'*blockVectorX); gramRBR=full(blockVectorR(:,activeMask)'*... blockVectorR(:,activeMask)); gramXBR=full(blockVectorX'*blockVectorR(:,activeMask)); else gramXBX=full(blockVectorBX'*blockVectorX); gramRBR=full(blockVectorBR(:,activeMask)'*... blockVectorR(:,activeMask)); gramXBR=full(blockVectorBX'*blockVectorR(:,activeMask)); end gramXBX=(gramXBX'+gramXBX)*0.5; gramRBR=(gramRBR'+gramRBR)*0.5; end for cond_try=1:2, %cond_try == 2 when restart if ~restart gramXAP=full(blockVectorAX'*blockVectorP(:,activeMask)); gramRAP=full(blockVectorAR(:,activeMask)'*... blockVectorP(:,activeMask)); gramPAP=full(blockVectorAP(:,activeMask)'*... blockVectorP(:,activeMask)); gramPAP=(gramPAP'+gramPAP)*0.5; if explicitGramFlag gramA = [ gramXAX gramXAR gramXAP gramXAR' gramRAR gramRAP gramXAP' gramRAP' gramPAP ]; else gramA = [ diag(lambda) gramXAR gramXAP gramXAR' gramRAR gramRAP gramXAP' gramRAP' gramPAP ]; end clear gramXAP gramRAP gramPAP if isempty(operatorB) gramXBP=full(blockVectorX'*blockVectorP(:,activeMask)); gramRBP=full(blockVectorR(:,activeMask)'*... blockVectorP(:,activeMask)); else gramXBP=full(blockVectorBX'*blockVectorP(:,activeMask)); gramRBP=full(blockVectorBR(:,activeMask)'*... blockVectorP(:,activeMask)); %or blockVectorR(:,activeMask)'*blockVectorBP(:,activeMask); end if explicitGramFlag if isempty(operatorB) gramPBP=full(blockVectorP(:,activeMask)'*... blockVectorP(:,activeMask)); else gramPBP=full(blockVectorBP(:,activeMask)'*... blockVectorP(:,activeMask)); end gramPBP=(gramPBP'+gramPBP)*0.5; gramB = [ gramXBX gramXBR gramXBP gramXBR' gramRBR gramRBP gramXBP' gramRBP' gramPBP ]; clear gramPBP else gramB=[eye(blockSize) zeros(blockSize,activeRSize) gramXBP zeros(blockSize,activeRSize)' eye(activeRSize) gramRBP gramXBP' gramRBP' eye(activePSize) ]; end clear gramXBP gramRBP; else if explicitGramFlag gramA = [ gramXAX gramXAR gramXAR' gramRAR ]; gramB = [ gramXBX gramXBR gramXBR' eye(activeRSize) ]; clear gramXAX gramXBX gramXBR else gramA = [ diag(lambda) gramXAR gramXAR' gramRAR ]; gramB = eye(blockSize+activeRSize); end clear gramXAR gramRAR; end condestG = log10(cond(gramB))+1; if (condestG/condestGmean > 2 && condestG > 2 )|| condestG > 8 %black magic - need to guess the restart if verbosityLevel fprintf('Restart on step %i as condestG %5.4e \n',... iterationNumber,condestG); end if cond_try == 1 && ~restart restart=1; %steepest descent restart for stability else warning('BLOPEX:lobpcg:IllConditioning',... 'Gramm matrix ill-conditioned: results unpredictable'); end else break end end [gramA,gramB]=eig(gramA,gramB); lambda=diag(gramB(1:blockSize,1:blockSize)); coordX=gramA(:,1:blockSize); clear gramA gramB if issparse(blockVectorX) coordX=sparse(coordX); end if ~restart blockVectorP = blockVectorR(:,activeMask)*... coordX(blockSize+1:blockSize+activeRSize,:) + ... blockVectorP(:,activeMask)*... coordX(blockSize+activeRSize+1:blockSize + ... activeRSize+activePSize,:); blockVectorAP = blockVectorAR(:,activeMask)*... coordX(blockSize+1:blockSize+activeRSize,:) + ... blockVectorAP(:,activeMask)*... coordX(blockSize+activeRSize+1:blockSize + ... activeRSize+activePSize,:); if ~isempty(operatorB) blockVectorBP = blockVectorBR(:,activeMask)*... coordX(blockSize+1:blockSize+activeRSize,:) + ... blockVectorBP(:,activeMask)*... coordX(blockSize+activeRSize+1:blockSize+activeRSize+activePSize,:); end else %use block steepest descent blockVectorP = blockVectorR(:,activeMask)*... coordX(blockSize+1:blockSize+activeRSize,:); blockVectorAP = blockVectorAR(:,activeMask)*... coordX(blockSize+1:blockSize+activeRSize,:); if ~isempty(operatorB) blockVectorBP = blockVectorBR(:,activeMask)*... coordX(blockSize+1:blockSize+activeRSize,:); end end blockVectorX = blockVectorX*coordX(1:blockSize,:) + blockVectorP; blockVectorAX=blockVectorAX*coordX(1:blockSize,:) + blockVectorAP; if ~isempty(operatorB) blockVectorBX=blockVectorBX*coordX(1:blockSize,:) + blockVectorBP; end clear coordX %%end RR lambdaHistory(1:blockSize,iterationNumber+1)=lambda; condestGhistory(iterationNumber+1)=condestG; if verbosityLevel fprintf('Iteration %i current block size %i \n',... iterationNumber,currentBlockSize); fprintf('Eigenvalues lambda %17.16e \n',lambda); fprintf('Residual Norms %e \n',residualNorms'); end end %The main step of the method was the CG cycle: end %Postprocessing %Making sure blockVectorX's "exactly" satisfy the blockVectorY constrains?? %Making sure blockVectorX's are "exactly" othonormalized by final "exact" RR if isempty(operatorB) gramXBX=full(blockVectorX'*blockVectorX); else if isnumeric(operatorB) blockVectorBX = operatorB*blockVectorX; else blockVectorBX = feval(operatorB,blockVectorX); end gramXBX=full(blockVectorX'*blockVectorBX); end gramXBX=(gramXBX'+gramXBX)*0.5; if isnumeric(operatorA) blockVectorAX = operatorA*blockVectorX; else blockVectorAX = feval(operatorA,blockVectorX); end gramXAX = full(blockVectorX'*blockVectorAX); gramXAX = (gramXAX + gramXAX')*0.5; %Raileigh-Ritz for blockVectorX, which is already operatorB-orthonormal [coordX,gramXBX] = eig(gramXAX,gramXBX); lambda=diag(gramXBX); if issparse(blockVectorX) coordX=sparse(coordX); end blockVectorX = blockVectorX*coordX; blockVectorAX = blockVectorAX*coordX; if ~isempty(operatorB) blockVectorBX = blockVectorBX*coordX; end %Computing all residuals if isempty(operatorB) if blockSize > 1 blockVectorR = blockVectorAX - ... blockVectorX*spdiags(lambda,0,blockSize,blockSize); else blockVectorR = blockVectorAX - blockVectorX*lambda; %to make blockVectorR full when lambda is just a scalar end else if blockSize > 1 blockVectorR=blockVectorAX - ... blockVectorBX*spdiags(lambda,0,blockSize,blockSize); else blockVectorR = blockVectorAX - blockVectorBX*lambda; %to make blockVectorR full when lambda is just a scalar end end residualNorms=full(sqrt(sum(conj(blockVectorR).*blockVectorR)')); residualNormsHistory(1:blockSize,iterationNumber)=residualNorms; if verbosityLevel fprintf('Final Eigenvalues lambda %17.16e \n',lambda); fprintf('Final Residual Norms %e \n',residualNorms'); end if verbosityLevel == 2 whos figure(491) semilogy((abs(residualNormsHistory(1:blockSize,1:iterationNumber-1)))'); title('Residuals for Different Eigenpairs','fontsize',16); ylabel('Eucledian norm of residuals','fontsize',16); xlabel('Iteration number','fontsize',16); %axis tight; %axis([0 maxIterations+1 1e-15 1e3]) set(gca,'FontSize',14); figure(492); semilogy(abs((lambdaHistory(1:blockSize,1:iterationNumber)-... repmat(lambda,1,iterationNumber)))'); title('Eigenvalue errors for Different Eigenpairs','fontsize',16); ylabel('Estimated eigenvalue errors','fontsize',16); xlabel('Iteration number','fontsize',16); %axis tight; %axis([0 maxIterations+1 1e-15 1e3]) set(gca,'FontSize',14); drawnow; end varargout(1)={failureFlag}; varargout(2)={lambdaHistory(1:blockSize,1:iterationNumber)}; varargout(3)={residualNormsHistory(1:blockSize,1:iterationNumber-1)}; end linear-algebra-2.2.4/inst/PaxHeaders/__init_linear_algebra__.m0000644000000000000000000000006215146653315021356 xustar0020 atime=1771787981 30 ctime=1771788142.227370642 linear-algebra-2.2.4/inst/__init_linear_algebra__.m0000644000175000017500000000311215146653315021667 0ustar00philipphilip## Copyright (C) 2016-2026 CarnĂ« Draug ## Copyright (C) 2011-2026 Philip Nienhuis ## ## This program is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 3 of the ## License, or (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, see ## . ## -*- texinfo -*- ## @deftypefn {} {} __init_linear_algebra__ () ## Undocumented internal function of linear-algebra package. ## ## Register Qt help files for GUI doc browser. ## ## @end deftypefn ## PKG_ADD: __init_linear_algebra__ () function __init_linear_algebra__ () ## Package documentation ## On package load, attempt to load docs try pkg_dir = fileparts (fullfile (mfilename ("fullpath"))); doc_file = fullfile (pkg_dir, "doc", "linear-algebra.qch"); doc_file = strrep (doc_file, '\', '/'); if exist(doc_file, "file") if exist("__event_manager_register_documentation__") __event_manager_register_documentation__ (doc_file); elseif exist("__event_manager_register_doc__") __event_manager_register_doc__ (doc_file); endif endif catch # do nothing end_try_catch endfunction linear-algebra-2.2.4/inst/PaxHeaders/rotparams.m0000644000000000000000000000006215146653315016620 xustar0020 atime=1771787981 30 ctime=1771788142.227370642 linear-algebra-2.2.4/inst/rotparams.m0000644000175000017500000000407715146653315017144 0ustar00philipphilip## Copyright (C) 2002 Etienne Grossmann ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn{Function File} {[@var{vstacked}, @var{astacked}] =} rotparams (@var{rstacked}) ## @cindex ## The function w = rotparams (r) - Inverse to rotv(). ## Using, @var{w} = rotparams(@var{r}) is such that ## rotv(w)*r' == eye(3). ## ## If used as, [v,a]=rotparams(r) , idem, with v (1 x 3) s.t. w == a*v. ## ## 0 <= norm(w)==a <= pi ## ## :-O !! Does not check if 'r' is a rotation matrix. ## ## Ignores matrices with zero rows or with NaNs. (returns 0 for them) ## ## @seealso{rotv} ## @end deftypefn function [vstacked, astacked] = rotparams (rstacked) N = size (rstacked,1) / 3; ## ang = 0 ; ## if length(varargin), ## if strcmp(varargin{1},'ang'), ang = 1; end ## end ok = all ( ! isnan (rstacked') ) & any ( rstacked' ); ok = min ( reshape (ok,3,N) ); ok = find (ok) ; ## keyboard vstacked = zeros (N,3); astacked = zeros (N,1); for j = ok, r = rstacked(3*j-2:3*j,:); [v,f] = eig (r); f = diag(f); [m,i] = min (abs (real (f)-1)); v = v(:,i); w = null (v'); u = w(:,1); a = u'*r*u; if a<1, a = real (acos (u'*r*u)); else a = 0; endif ## Check orientation x=r*u; if v'*[0 -u(3) u(2); u(3) 0 -u(1);-u(2) u(1) 0]*x < 0, v=-v; endif if nargout <= 1, v = v*a; endif vstacked(j,:) = -v'; astacked(j) = a; endfor endfunction linear-algebra-2.2.4/inst/PaxHeaders/@kronprod0000644000000000000000000000013215146653556016320 xustar0030 mtime=1771788142.204370778 30 atime=1771788142.227370642 30 ctime=1771788142.227370642 linear-algebra-2.2.4/inst/@kronprod/0000755000175000017500000000000015146653556016713 5ustar00philipphiliplinear-algebra-2.2.4/inst/@kronprod/PaxHeaders/rows.m0000644000000000000000000000006215146653315017540 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/rows.m0000644000175000017500000000213515146653315020055 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} rows (@var{KP}) ## Return the number of rows in the Kronecker product @var{KP}. ## @seealso{rows, @@kronprod/size, @@kronprod/columns, @@kronprod/numel} ## @end deftypefn function retval = rows (KP) if (nargin != 1) print_usage (); endif if (!isa (KP, "kronprod")) error ("rows: input must be of class 'kronprod'"); endif retval = rows (KP.A) * rows (KP.B); endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/sparse.m0000644000000000000000000000006215146653315020043 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/sparse.m0000644000175000017500000000225215146653315020360 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} sparse (@var{KP}) ## Return the Kronecker product @var{KP} represented as a sparse matrix. ## @seealso{sparse, @@kronprod/issparse, @@kronprod/full} ## @end deftypefn function retval = sparse (KP) if (nargin != 1) print_usage (); endif if (!isa (KP, "kronprod")) error ("sparse: input argument must be of class 'kronprod'"); endif ## XXX: Would this be better? kron (sparse (KP.A), sparse (KP.B))) retval = sparse (kron (KP.A, KP.B)); endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/size.m0000644000000000000000000000006215146653315017520 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/size.m0000644000175000017500000000255015146653315020036 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} size (@var{KP}) ## @deftypefnx{Function File} size (@var{KP}, @var{dim}) ## Return the size of the Kronecker product @var{KP} as a vector. ## @seealso{size, @@kronprod/rows, @@kronprod/columns, @@kronprod/numel} ## @end deftypefn function retval = size (KP, dim) if (nargin < 1) print_usage (); endif if (!isa (KP, "kronprod")) error ("size: input must be of class 'kronprod'"); endif if (nargin > 1 && !(isscalar (dim) && dim == round (dim) && dim > 0)) error ("size: optional second input must be a positive integer"); endif retval = size (KP.A) .* size (KP.B); if (nargin > 1) retval = retval (dim); endif endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/rank.m0000644000000000000000000000006215146653315017501 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/rank.m0000644000175000017500000000222315146653315020014 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} rank (@var{KP}) ## Return the rank of the Kronecker product @var{KP}. This is computed as the ## product of the ranks of the matrices forming the product. ## @seealso{rank, @@kronprod/det, @@kronprod/trace} ## @end deftypefn function retval = rank (KP) if (nargin != 1) print_usage (); endif if (!isa (KP, "kronprod")) error ("rank: input must be of class 'kronprod'"); endif retval = rank (KP.A) * rank (KP.B); endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/inv.m0000644000000000000000000000006215146653315017342 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/inv.m0000644000175000017500000000337515146653315017666 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} inv (@var{KP}) ## Return the inverse of the Kronecker product @var{KP}. ## ## If @var{KP} is the Kronecker product of two square matrices @var{A} and @var{B}, ## the inverse will be computed as the Kronecker product of the inverse of ## @var{A} and @var{B}. ## ## If @var{KP} is square but not a Kronecker product of square matrices, the ## inverse will be computed using the SVD ## @seealso{@@kronprod/sparse} ## @end deftypefn function retval = inv (KP) ## Check input if (nargin != 1) print_usage (); endif if (!isa (KP, "kronprod")) error ("inv: input argument must be of class 'kronprod'"); endif ## Do the computations [n, m] = size (KP.A); [q, r] = size (KP.B); if (n == m && q == r) # A and B are both square retval = kronprod (inv (KP.A), inv (KP.B)); elseif (n*q == m*r) # kron (A, B) is square ## We use the SVD to compute the inverse. ## XXX: Should we use 'eig' instead? [U, S, V] = svd (KP); retval = U * (1./S) * V'; else error ("inv: argument must be a square matrix"); endif endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/isreal.m0000644000000000000000000000006215146653315020025 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/isreal.m0000644000175000017500000000216615146653315020346 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} isreal (@var{KP}) ## Return @t{true} if the Kronecker product @var{KP} is real, i.e. has no ## imaginary components. ## @seealso{isreal, @@kronprod/iscomplex} ## @end deftypefn function retval = isreal (KP) if (nargin != 1) print_usage (); endif if (!isa (KP, "kronprod")) error ("isreal: input argument must be of class 'kronprod'"); endif retval = (isreal (KP.A) & isreal (KP.B)); endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/rdivide.m0000644000000000000000000000006215146653315020174 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/rdivide.m0000644000175000017500000000350215146653315020510 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} rdivide (@var{a}, @var{b}) ## Perform element-by-element right division. ## @end deftypefn function retval = rdivide (a, b) ## Check input if (nargin < 2) print_usage (); endif if (! (ismatrix (a) && isnumeric (a) && ismatrix (b) && isnumeric (b))) error ("rdivide: input arguments must be scalars or matrices"); endif if (!size_equal (a, b) || !isscalar (b)) error ("times: nonconformant arguments (op1 is %dx%d, op2 is %dx%d)", rows (a), columns (a), rows (b), columns (b)); endif ## Take action depending on input if (isscalar (a) && isa (b, "kronprod")) retval = kronprod (a ./ b.A, 1 ./ b.B); elseif (isa (a, "kronprod") && isscalar (b)) if (numel (a.A) < numel (a.B)) retval = kronprod (a.A ./ b, a.B); else retval = kronprod (a.A, a.B ./ b); endif elseif (isa (a, "kronprod") && isa (b, "kronprod")) ## XXX: Can we do something smarter here? retval = full (a) ./ full (b); else ## XXX: We should probably handle sparse cases and all sorts of other ## situations better here retval = full (a) ./ full (b); endif endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/not_done0000644000000000000000000000013215146653556020125 xustar0030 mtime=1771788142.201370796 30 atime=1771788142.228370636 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/not_done/0000755000175000017500000000000015146653556020520 5ustar00philipphiliplinear-algebra-2.2.4/inst/@kronprod/not_done/PaxHeaders/eig.m0000644000000000000000000000006215146653315021117 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/not_done/eig.m0000644000175000017500000000454715146653315021445 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{lambda} =} eig (@var{KP}) ## @deftypefnx{Function File} {[var{V}, @var{lambda}] =} eig (@var{KP}) ## XXX: Write help text ## @seealso{eig, @kronprod/svd} ## @end deftypefn function [V, lambda] = eig (KP, A) ## XXX: This implementation provides a different permutation of eigenvalues and ## eigenvectors compared to 'eig (full (KP))' ## Check input if (nargin == 0 || nargin > 2) print_usage (); endif if (!isa (KP, "kronprod")) error ("eig: first input argument must be of class 'kronprod'"); endif if (!issquare (KP)) error ("eig: first input must be a square matrix"); endif ## Take action if (nargin == 1) if (nargout <= 1) ## Only eigenvalues were requested if (issquare (KP.A) && issquare (KP.B)) lambda_A = eig (KP.A); lambda_B = eig (KP.B); V = kronprod (lambda_A, lambda_B); else ## We should be able to do this using SVD error ("eig not implemented (yet) for Kronecker products of non-square matrices"); endif elseif (nargout == 2) ## Both eigenvectors and eigenvalues were requested if (issquare (KP.A) && issquare (KP.B)) [V_A, lambda_A] = eig (KP.A); [V_B, lambda_B] = eig (KP.B); V = kronprod (V_A, V_B); lambda = kronprod (lambda_A, lambda_B); else ## We should be able to do this using SVD error ("eig not implemented (yet) for Kronecker products of non-square matrices"); endif endif elseif (nargin == 2) ## Solve generalised eigenvalue problem ## XXX: Is there a fancy way of doing this? [V, lambda] = eig (full (KP), full (A)); endif endfunction linear-algebra-2.2.4/inst/@kronprod/not_done/PaxHeaders/svd.m0000644000000000000000000000006215146653315021147 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/not_done/svd.m0000644000175000017500000000321615146653315021465 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} svd (@var{KP}) ## XXX: Write documentation ## @end deftypefn function [U, S, V] = svd (KP) if (nargin < 1) print_usage (); endif if (!isa (KP, "kronprod")) error ("svd: input must be of class 'kronprod'"); endif ## XXX: I don't think this works properly for non-square A and B if (nargout <= 1) ## Only singular values were requested S_A = svd (KP.A); S_B = svd (KP.B); U = sort (kron (S_A, S_B), "descend"); elseif (nargout == 3) ## The full SVD was requested [U_A, S_A, V_A] = svd (KP.A); [U_B, S_B, V_B] = svd (KP.B); ## Compute and sort singular values [sv, idx] = sort (kron (diag (S_A), diag (S_B)), "descend"); ## Form matrices S = resize (diag (sv), [rows(KP), columns(KP)]); #Pu = eye (rows (KP)) (idx, :); U = kronprod (U_A, U_B, idx); #Pv = eye (columns (KP)) (idx, :); V = kronprod (V_A, V_B, idx); else print_usage (); endif endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/det.m0000644000000000000000000000006215146653315017322 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/det.m0000644000175000017500000000354115146653315017641 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} det (@var{KP}) ## Compute the determinant of a Kronecker product. ## ## If @var{KP} is the Kronecker product of the @var{n}-by-@var{n} matrix @var{A} ## and the @var{q}-by-@var{q} matrix @var{B}, then the determinant is computed ## as ## ## @example ## det (@var{A})^q * det (@var{B})^n ## @end example ## ## If @var{KP} is not a Kronecker product of square matrices the determinant is ## computed by forming the full matrix and then computing the determinant. ## @seealso{det, @@kronprod/trace, @@kronprod/rank, @@kronprod/full} ## @end deftypefn function retval = det (KP) ## Check input if (nargin != 1) print_usage (); endif if (!isa (KP, "kronprod")) error ("det: input argument must be of class 'kronprod'"); endif if (!issquare (KP)) error ("det: argument must be a square matrix"); endif ## Take action [n, m] = size (KP.A); [q, r] = size (KP.B); if (n == m && q == r) # A and B are both square retval = (det (KP.A)^q) * (det (KP.B)^n); elseif (n*q == m*r) # kron (A, B) is square ## XXX: Can we do something smarter here? We should be able to use the SVD... retval = det (full (KP)); endif endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/mpower.m0000644000000000000000000000006215146653315020057 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/mpower.m0000644000175000017500000000257715146653315020406 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} mpower (@var{KP}, @var{k}) ## Perform matrix power operation. ## @end deftypefn function retval = mpower (KP, k) ## Check input if (nargin != 2) print_usage (); endif if (! (ismatrix (KP) && isnumeric (KP))) error ("mpower: first input argument must be a matrix"); endif if (! isscalar (k)) error ("mpower: second input argument must be a scalar"); endif ## Do the actual computation if (issquare (KP.A) && issquare (KP.B) && k == round (k)) retval = kronprod (KP.A^k, KP.B^k); elseif (issquare (KP)) ## XXX: Can we do something smarter here? retval = full (KP)^k; else error ("for A^b, A must be square"); endif endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/trace.m0000644000000000000000000000006215146653315017644 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/trace.m0000644000175000017500000000267215146653315020167 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} trace (@var{KP}) ## Returns the trace of the Kronecker product @var{KP}. ## ## If @var{KP} is a Kronecker product of two square matrices, the trace is ## computed as the product of the trace of these two matrices. Otherwise the ## trace is computed by forming the full matrix. ## @seealso{@@kronprod/det, @@kronprod/rank, @@kronprod/full} ## @end deftypefn function retval = trace (KP) if (nargin != 1) print_usage (); endif if (!isa (KP, "kronprod")) error ("trace: input must be of class 'kronprod'"); endif if (issquare (KP.A) && issquare (KP.B)) retval = trace (KP.A) * trace (KP.B); else ## XXX: Can we do something smarter here? Using 'eig' or 'svd'? retval = trace (full (KP)); endif endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/display.m0000644000000000000000000000006215146653315020213 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/display.m0000644000175000017500000000307215146653315020531 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} display (@var{KP}) ## Show the content of the Kronecker product @var{KP}. To avoid evaluating the ## Kronecker product, this function displays the two matrices defining the product. ## To display the actual values of @var{KP}, use @code{display (full (@var{KP}))}. ## @seealso{@@kronprod/displ, @@kronprod/full} ## @end deftypefn function display (KP) if (nargin != 1) print_usage (); endif if (!isa (KP, "kronprod")) error ("display: input argument must be of class 'kronprod'"); endif if (isempty (KP.P)) disp ("Kronecker Product of A and B with"); disp ("A = "); disp (KP.A); disp ("B = "); disp (KP.B); else disp ("Permuted Kronecker Product of A and B (i.e. P * kron (A, B) * P') with"); disp ("A = "); disp (KP.A); disp ("B = "); disp (KP.B); disp ("P = "); disp (KP.P); endif endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/columns.m0000644000000000000000000000006215146653315020226 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/columns.m0000644000175000017500000000215515146653315020545 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} columns (@var{KP}) ## Return the number of columns in the Kronecker product @var{KP}. ## @seealso{@@kronprod/rows, @@kronprod/size, @@kronprod/numel} ## @end deftypefn function retval = columns (KP) if (nargin != 1) print_usage (); endif if (!isa (KP, "kronprod")) error ("columns: input argument must be of class 'kronprod'"); endif retval = columns (KP.A) * columns (KP.B); endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/numel.m0000644000000000000000000000006215146653315017666 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/numel.m0000644000175000017500000000215415146653315020204 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} numel (@var{KP}) ## Return the number of elements in the Kronecker product @var{KP}. ## @seealso{numel, @@kronprod/rows, @@kronprod/columns, @@kronprod/size} ## @end deftypefn function retval = numel (KP) if (nargin != 1) print_usage (); endif if (!isa (KP, "kronprod")) error ("numel: input must be of class 'kronprod'"); endif retval = prod (size (KP.A) .* size (KP.B)); endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/ctranspose.m0000644000000000000000000000006215146653315020727 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/ctranspose.m0000644000175000017500000000226215146653315021245 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} ctranspose (@var{KP}) ## The complex conjugate transpose of a Kronecker product. This is equivalent ## to ## ## @example ## @var{KP}' ## @end example ## @seealso{ctranspose, @@kronprod/transpose} ## @end deftypefn function retval = ctranspose (KP) if (nargin != 1) print_usage (); endif if (!isa (KP, "kronprod")) error ("ctranspose: input argument must be of class 'kronprod'"); endif retval = kronprod (ctranspose (KP.A), ctranspose (KP.B)); endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/ismatrix.m0000644000000000000000000000006215146653315020406 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/ismatrix.m0000644000175000017500000000162015146653315020721 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} ismatrix (@var{KP}) ## Return @t{true} to indicate that the Kronecker product @var{KP} always is a ## matrix. ## @end deftypefn function retval = ismatrix (KP) retval = true; endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/full.m0000644000000000000000000000006215146653315017510 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/full.m0000644000175000017500000000272015146653315020025 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} full (@var{KP}) ## Return the full matrix representation of the Kronecker product @var{KP}. ## ## If @var{KP} is the Kronecker product of an @var{n}-by-@var{m} matrix and a ## @var{q}-by-@var{r} matrix, then the result is a @var{n}@var{q}-by-@var{m}@var{r} ## matrix. Thus, the result can require vast amount of memory, so this function ## should be avoided whenever possible. ## @seealso{full, @@kronprod/sparse} ## @end deftypefn function retval = full (KP) if (nargin != 1) print_usage (); endif if (!isa (KP, "kronprod")) error ("full: input argument must be of class 'kronprod'"); endif retval = full (kron (KP.A, KP.B)); if (!isempty (KP.P)) #retval = KP.P * retval * KP.P'; retval = retval (KP.P, KP.P); endif endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/minus.m0000644000000000000000000000006215146653315017701 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/minus.m0000644000175000017500000000314015146653315020213 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} minus (@var{a}, @var{a}) ## Return the difference between a Kronecker product and another matrix. This is performed ## by forming the full matrix of both inputs and is as such a potential expensive ## operation. ## @seealso{minus, @@kronprod/plus} ## @end deftypefn function retval = minus (M1, M2) if (nargin != 2) print_usage (); endif if (! (ismatrix (M1) && isnumeric (M1) && ismatrix (M2) && isnumeric (M2))) error ("minus: both input arguments must be matrices"); endif if (!size_equal (M1, M2)) error ("minus: nonconformant arguments (op1 is %dx%d, op2 is %dx%d)", rows (M1), columns (M1), rows (M2), columns (M2)); endif ## XXX: Can we do something smarter here? if (issparse (M1)) M1 = sparse (M1); else M1 = full (M1); endif if (issparse (M2)) M2 = sparse (M2); else M2 = full (M2); endif retval = M1 - M2; endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/mldivide.m0000644000000000000000000000006215146653315020343 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/mldivide.m0000644000175000017500000000412315146653315020657 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} mldivide (@var{M1}, @var{M2}) ## Perform matrix left division. ## @end deftypefn function retval = mldivide (M1, M2) ## Check input if (nargin != 2) print_usage (); endif if (! (ismatrix (M1) && isnumeric (M1) && ismatrix (M2) && isnumeric (M2))) error ("mldivide: both input arguments must be matrices"); endif if (rows (M1) != rows (M2)) error ("mldivide: nonconformant arguments (op1 is %dx%d, op2 is %dx%d)", rows (M1), columns (M1), rows (M2), columns (M2)); endif ## Take action depending on types M1_is_KP = isa (M1, "kronprod"); M2_is_KP = isa (M2, "kronprod"); if (M1_is_KP && M2_is_KP) # Left division of Kronecker Products error ("mldividide: this part not yet implemented as I'm lazy..."); elseif (M1_is_KP) # Left division of Kronecker Product and Matrix ## XXX: Does this give the same minimum-norm solution as when using ## XXX: full (M1) \ M2 ## XXX: ? It is the same when M1 is invertible. retval = zeros (columns (M1), columns (M2)); for n = 1:columns (M2) M = reshape (M2 (:, n), [rows(M1.B), rows(M1.A)]); retval (:, n) = vec ((M1.A \ (M1.B \ M)')'); endfor elseif (M2_is_KP) # Left division of Matrix and Kronecker Product error ("mldividide: this part not yet implemented as I'm lazy..."); else error ("mldivide: internal error for 'kronprod'"); endif endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/issquare.m0000644000000000000000000000006215146653315020402 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/issquare.m0000644000175000017500000000212715146653315020720 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} issquare (@var{KP}) ## Return @t{true} if the Kronecker product @var{KP} is a square matrix. ## @seealso{@@kronprod/size} ## @end deftypefn function retval = issquare (KP) if (nargin != 1) print_usage (); endif if (!isa (KP, "kronprod")) error ("issquare: input argument must be of class 'kronprod'"); endif s = size (KP); retval = (s (1) == s (2)); endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/iscomplex.m0000644000000000000000000000006215146653315020551 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/iscomplex.m0000644000175000017500000000216515146653315021071 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} iscomplex (@var{KP}) ## Return @t{true} if the Kronecker product @var{KP} contains any complex values. ## @seealso{iscomplex, @@kronprod/isreal} ## @end deftypefn function retval = iscomplex (KP) if (nargin != 1) print_usage (); endif if (!isa (KP, "kronprod")) error ("iscomplex: input argument must be of class 'kronprod'"); endif retval = (iscomplex (KP.A) || iscomplex (KP.B)); endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/mtimes.m0000644000000000000000000000006215146653315020044 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/mtimes.m0000644000175000017500000000615615146653315020370 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} mtimes (@var{KP1}, @var{KP2}) ## Perform matrix multiplication operation. ## @end deftypefn function retval = mtimes (M1, M2) ## Check input if (nargin == 0) print_usage (); elseif (nargin == 1) ## This seems to be what happens for full and sparse matrices, so we copy this behaviour retval = M1; return; endif if (! (ismatrix (M1) && isnumeric (M1) && ismatrix (M2) && isnumeric (M2))) error ("mtimes: input arguments must be matrices"); endif if (columns (M1) != rows (M2)) error ("mtimes: nonconformant arguments (op1 is %dx%d, op2 is %dx%d)", rows (M1), columns (M1), rows (M2), columns (M2)); endif ## Take action depending on input types M1_is_KP = isa (M1, "kronprod"); M2_is_KP = isa (M2, "kronprod"); if (M1_is_KP && M2_is_KP) # Product of Kronecker Products ## Check if the size match such that the result is a Kronecker Product if (columns (M1.A) == rows (M2.A) && columns (M1.B) == rows (M2.B)) retval = kronprod (M1.A * M2.A, M1.B * M2.B); else ## Form the full matrix of the smallest matrix and use that to compute the ## final product ## XXX: Can we do something smarter here? numel1 = numel (M1); numel2 = numel (M2); if (numel1 < numel2) retval = full (M1) * M2; else retval = M1 * full (M2); endif endif elseif (M1_is_KP && isscalar (M2)) # Product of Kronecker Product and scalar if (numel (M1.A) < numel (M1.B)) retval = kronprod (M2 * M1.A, M1.B); else retval = kronprod (M1.A, M2 * M1.B); endif elseif (M1_is_KP && ismatrix (M2)) # Product of Kronecker Product and Matrix retval = zeros (rows (M1), columns (M2)); for n = 1:columns (M2) M = reshape (M2 (:, n), [columns(M1.B), columns(M1.A)]); retval (:, n) = vec (M1.B * M * M1.A'); endfor elseif (isscalar (M1) && M2_is_KP) # Product of scalar and Kronecker Product if (numel (M2.A) < numel (M2.B)) retval = kronprod (M1 * M2.A, M2.B); else retval = kronprod (M2.A, M1 * M2.B); endif elseif (ismatrix (M1) && M2_is_KP) # Product of Matrix and Kronecker Product retval = zeros (rows (M1), columns (M2)); for n = 1:rows (M1) M = reshape (M1 (n, :), [rows(M2.B), rows(M2.A)]); retval (n, :) = vec (M2.B' * M * M2.A); endfor else error ("mtimes: internal error for 'kronprod'"); endif endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/times.m0000644000000000000000000000006215146653315017667 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/times.m0000644000175000017500000000426315146653315020210 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} times (@var{KP}, @var{KP2}) ## Perform elemtn-by-element multiplication. ## @end deftypefn function retval = times (M1, M2) ## Check input if (nargin == 0) print_usage (); elseif (nargin == 1) ## This seems to be what happens for full and sparse matrices, so we copy this behaviour retval = M1; return; endif if (! (ismatrix (M1) && isnumeric (M1) && ismatrix (M2) && isnumeric (M2))) error ("times: input arguments must be matrices"); endif if (! size_equal (M1, M2)) error ("times: nonconformant arguments (op1 is %dx%d, op2 is %dx%d)", rows (M1), columns (M1), rows (M2), columns (M2)); endif ## Take action depending on input types M1_is_KP = isa (M1, "kronprod"); M2_is_KP = isa (M2, "kronprod"); ## Product of Kronecker Products ## Check if the size match such that the result is a Kronecker Product if (M1_is_KP && M2_is_KP && size_equal (M1.A, M2.A) && size_equal (M1.B, M2.B)) retval = kronprod (M1.A .* M2.A, M1.B .* M2.B); elseif (isscalar (M1) || isscalar (M2)) # Product of Kronecker Product and scalar retval = M1 * M2; ## Forward to mtimes. else # All other cases. ## Form the full matrix or sparse matrix of both matrices ## XXX: Can we do something smarter here? if (issparse (M1)) M1 = sparse (M1); else M1 = full (M1); endif if (issparse (M2)) M2 = sparse (M2); else M2 = full (M2); endif retval = M1 .* M2; endif endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/uminus.m0000644000000000000000000000006215146653315020066 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/uminus.m0000644000175000017500000000240115146653315020377 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} uminus (@var{KP}) ## Returns the unary minus operator working on the Kronecker product @var{KP}. ## This corresponds to @code{-@var{KP}} and simply returns the Kronecker ## product with the sign of the smallest matrix in the product reversed. ## @seealso{@@kronprod/uminus} ## @end deftypefn function KP = uminus (KP) if (nargin != 1) print_usage (); endif if (!isa (KP, "kronprod")) error ("uplus: input must be of class 'kronprod'"); endif if (numel (KP.A) < numel (KP.B)) KP.A *= -1; else KP.B *= -1; endif endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/uplus.m0000644000000000000000000000006215146653315017716 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/uplus.m0000644000175000017500000000174715146653315020243 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} uplus (@var{KP}) ## Returns the unary plus operator working on the Kronecker product @var{KP}. ## This corresponds to @code{+@var{KP}} and simply returns the Kronecker ## product unchanged. ## @seealso{@@kronprod/uminus} ## @end deftypefn function KP = uplus (KP) endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/kronprod.m0000644000000000000000000000006215146653315020404 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/kronprod.m0000644000175000017500000000325715146653315020727 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} kronprod (@var{A}, @var{B}) ## @deftypefnx{Function File} kronprod (@var{A}, @var{B}, @var{P}) ## Construct a Kronecker product object. ## XXX: Write proper documentation ## ## With two input arguments, the following matrix is represented: kron (A, B); ## ## With three input arguments, the following matrix is represented: P * kron (A, B) * P' ## (P must be a permutation matrix) ## ## @end deftypefn function retval = kronprod (A, B, P) if (nargin == 0) KP.A = KP.B = KP.P = []; elseif (nargin == 2 && ismatrix (A) && isnumeric (A) && ismatrix (B) && isnumeric (B)) KP.A = A; KP.B = B; KP.P = []; elseif (nargin == 3 && ismatrix (A) && isnumeric (A) && ismatrix (B) && isnumeric (B)) # && strcmp (typeinfo (P), "permutation matrix")) # FIXME: why is above line commented-out? ## XXX: Check that the size of P is correct KP.A = A; KP.B = B; KP.P = P; else print_usage (); endif retval = class (KP, "kronprod"); endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/plus.m0000644000000000000000000000006215146653315017531 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/plus.m0000644000175000017500000000333415146653315020050 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} plus (@var{a}, @var{a}) ## Return the sum of a Kronecker product and another matrix. This is performed ## by forming the full matrix of both inputs and is as such a potential expensive ## operation. ## @seealso{plus, @@kronprod/minus} ## @end deftypefn function retval = plus (M1, M2) if (nargin == 0 || nargin > 2) print_usage (); elseif (nargin == 1) ## This seems to be the behaviour for the built-in types so we copy that retval = M1; return; endif if (! (ismatrix (M1) && isnumeric (M1) && ismatrix (M2) && isnumeri (M2))) error ("plus: input arguments must be matrics"); endif if (!size_equal (M1, M2)) error ("plus: nonconformant arguments (op1 is %dx%d, op2 is %dx%d)", rows (M1), columns (M1), rows (M2), columns (M2)); endif ## XXX: Can we do something smarter here? if (issparse (M1)) M1 = sparse (M1); else M1 = full (M1); endif if (issparse (M2)) M2 = sparse (M2); else M2 = full (M2); endif retval = M1 + M2; endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/size_equal.m0000644000000000000000000000006215146653315020707 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/size_equal.m0000644000175000017500000000163615146653315021231 0ustar00philipphilip## Copyright (C) 2010 VZLU Prague ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} size_equal (@dots{}) ## True if all input have same dimensions. ## @end deftypefn function iseq = size_equal (varargin) iseq = isequal (cellfun (@size, varargin, "UniformOutput", false){:}); endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/disp.m0000644000000000000000000000006215146653315017505 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/disp.m0000644000175000017500000000221015146653315020014 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} disp (@var{KP}) ## Show the content of the Kronecker product @var{KP}. To avoid evaluating the ## Kronecker product, this function displays the two matrices defining the product. ## To display the actual values of @var{KP}, use @code{disp (full (@var{KP}))}. ## ## This function is equivalent to @code{@@kronprod/display}. ## @seealso{@@kronprod/display, @@kronprod/full} ## @end deftypefn function disp (KP) display (KP); endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/issparse.m0000644000000000000000000000006215146653315020377 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/issparse.m0000644000175000017500000000215315146653315020714 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} issparse (@var{KP}) ## Return @t{true} if one of the matrices in the Kronecker product @var{KP} ## is sparse. ## @seealso{@@kronprod/sparse} ## @end deftypefn function retval = issparse (KP) if (nargin != 1) print_usage (); endif if (!isa (KP, "kronprod")) error ("issparse: input argument must be of class 'kronprod'"); endif retval = (issparse(KP.A) || issparse(KP.B)); endfunction linear-algebra-2.2.4/inst/@kronprod/PaxHeaders/transpose.m0000644000000000000000000000006215146653315020564 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@kronprod/transpose.m0000644000175000017500000000225015146653315021077 0ustar00philipphilip## Copyright (C) 2010 Soren Hauberg ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this file. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} transpose (@var{KP}) ## Returns the transpose of the Kronecker product @var{KP}. This is equivalent ## to ## ## @example ## @var{KP}.' ## @end example ## @seealso{transpose, @@kronprod/ctranspose} ## @end deftypefn function retval = transpose (KP) if (nargin != 1) print_usage (); endif if (!isa (KP, "kronprod")) error ("transpose: input must be of class 'kronprod'"); endif retval = kronprod (transpose (KP.A), transpose (KP.B)); endfunction linear-algebra-2.2.4/inst/PaxHeaders/cartprod.m0000644000000000000000000000006215146653315016426 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/cartprod.m0000644000175000017500000000346715146653315016754 0ustar00philipphilip## Copyright (C) 2008 Muthiah Annamalai ## Copyright (C) 2010 VZLU Prague ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {} cartprod (@var{varargin}) ## ## Computes the cartesian product of given column vectors ( row vectors ). ## The vector elements are assumend to be numbers. ## ## Alternatively the vectors can be specified by as a matrix, by its columns. ## ## To calculate the cartesian product of vectors, ## P = A x B x C x D ... . Requires A, B, C, D be column vectors. ## The algorithm is iteratively calcualte the products, ## ( ( (A x B ) x C ) x D ) x etc. ## ## @example ## @group ## cartprod(1:2,3:4,0:1) ## ans = 1 3 0 ## 2 3 0 ## 1 4 0 ## 2 4 0 ## 1 3 1 ## 2 3 1 ## 1 4 1 ## 2 4 1 ## @end group ## @end example ## @end deftypefn ## @seealso{kron} function p = cartprod (varargin) if (nargin < 1) print_usage (); elseif (nargin == 1) p = varargin{1}; endif [p{1:nargin}] = ndgrid (varargin{:}); p = cat (nargin+1, p{:}); p = reshape (p, [], nargin); endfunction %!assert(cartprod(1:2,0:1),[1 0; 2 0; 1 1; 2 1]) linear-algebra-2.2.4/inst/PaxHeaders/circulant_matrix_vector_product.m0000644000000000000000000000006215146653315023302 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/circulant_matrix_vector_product.m0000644000175000017500000000345015146653315023620 0ustar00philipphilip## Copyright (C) 2012 Nir Krakauer ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn{Function File} {@var{y} =} circulant_matrix_vector_product (@var{v}, @var{x}) ## ## Fast, compact calculation of the product of a circulant matrix with a vector@* ## Given @var{n}*1 vectors @var{v} and @var{x}, return the matrix-vector product @var{y} = @var{C}@var{x}, where @var{C} is the @var{n}*@var{n} circulant matrix that has @var{v} as its first column ## ## Theoretically the same as @code{make_circulant_matrix(x) * v}, but does not form @var{C} explicitly; uses the discrete Fourier transform ## ## Because of roundoff, the returned @var{y} may have a small imaginary component even if @var{v} and @var{x} are real (use @code{real(y)} to remedy this) ## ## Reference: Gene H. Golub and Charles F. Van Loan, Matrix Computations, 3rd Ed., Section 4.7.7 ## ## @seealso{gallery, circulant_eig, circulant_inv} ## @end deftypefn function y = circulant_matrix_vector_product (v, x) xf = fft(x); vf = fft(v); z = vf .* xf; y = ifft(z); endfunction %!shared v,x %! v = [1 2 3]'; x = [2 5 6]'; %!assert (circulant_matrix_vector_product(v, x), circulant_make_matrix(v)*x, eps); linear-algebra-2.2.4/inst/PaxHeaders/vec_projection.m0000644000000000000000000000006215146653315017621 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/vec_projection.m0000644000175000017500000000551515146653315020143 0ustar00philipphilip## Copyright (C) 2013 Her Majesty The Queen In Right of Canada ## Developed by Defence Research & Development Canada ## ## This file is part of Octave. ## ## Octave is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## Octave is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{out} =} vec_projection (@var{x}, @var{y}) ## Compute the vector projection of a 3-vector onto another. ## @var{x} : size 1 x 3 and @var{y} : size 1 x 3 @var{tol} : size 1 x 1 ## ## @example ## vec_projection ([1,0,0], [0.5,0.5,0]) ## @result{} 0.7071 ## @end example ## ## Vector projection of @var{x} onto @var{y}, both are 3-vectors, ## returning the value of @var{x} along @var{y}. Function uses dot product, ## Euclidean norm, and angle between vectors to compute the proper length along ## @var{y}. ## @end deftypefn ## Author: DRE 2013 ## Created: 10 June 2013 function out = vec_projection (x, y, tol) %% Error handling if (size(x,1)!=1 && size(x,2)!=3) out = -1 warning ("vec_projection: first vector is not 1x3 3-vector"); endif if (size(y,1)!=1 && size(y,2)!=3) out = -1 warning ("vec_projection: second vector is not 1x3 3-vector"); endif %% Compute Dot Product Method: proj(x,y) = |x|*cos(theta) dp = dot (x,y); %% Compute Angle Between X and Y theta = dp / (norm (x,2) * norm (y,2)); theta = acos (theta); %%theta_d = 360/(2*pi) *(theta)%% for viewing %% Compute X Projected onto Y Unit Vector temp = norm (x,2) *(cos (theta)); %% validate with third argument if needed if (nargin == 3) %% Alternate Solution proj(x,y) = x * y/norm(y,2) %% Compute Y Unit Vector unit_y = y / (norm (y,2)); %% Euclidean 2-norm temp2 = dot (x,unit_y); if (temp2 - temp <= tol) out = temp; else out = -1; warning ("vec_projection: Warning, vector projection exceeded tolerance"); endif endif %% Final Stage output out = temp; endfunction %!test %! assert (vec_projection ([1,0,0], [0.5,0.5,0]), 0.70711,1e-5); %! assert (vec_projection ([1,2000,0], [0.5,15,0]), 1998.9, 1e-1); %! assert (vec_projection ([1,-2000,0], [0.5,15,0]), -1998.9, 1e-1); %! assert (vec_projection ([7,7,0], [15,0,0]), 7.000, 1e-10); %! assert (vec_projection ([1,1,0], [1.05,0.94,0]), 1.4121, 1e-4); %! assert (vec_projection ([1,1.1,0], [1.05,0.94,0]), 1.4788, 1e-4); linear-algebra-2.2.4/inst/PaxHeaders/@blksparse0000644000000000000000000000013215146653556016450 xustar0030 mtime=1771788142.198370814 30 atime=1771788142.228370636 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@blksparse/0000755000175000017500000000000015146653556017043 5ustar00philipphiliplinear-algebra-2.2.4/inst/@blksparse/PaxHeaders/blksparse.m0000644000000000000000000000006215146653315020664 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@blksparse/blksparse.m0000644000175000017500000000647415146653315021213 0ustar00philipphilip## Copyright (C) 2010 VZLU Prague ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn{Function File} {@var{s} =} blksparse (@var{i}, @var{j}, @var{sv}) ## @deftypefnx{Function File} {@var{s} =} blksparse (@var{i}, @var{j}, @var{sv}, @var{m}, @var{n}) ## @deftypefnx{Function File} {@var{s} =} blksparse (@dots{}, @var{mode}) ## ## Construct a block sparse matrix. The meaning of arguments is analogous to the ## built-in @code{sparse} function, except that @var{i}, @var{j} are indices of ## blocks rather than elements, and @var{sv} is a 3-dimensional array, the first two ## dimensions determining the block size. Optionally, @var{m} and @var{n} can be ## specified as the true block dimensions; if not, the maximum values of @var{i}, @var{j} ## are taken instead. The resulting sparse matrix has the size ## ## @example ## [@var{m}*@var{p}, @var{n}*@var{q}] ## @end example ## ## where ## ## @example ## @var{p} = size (@var{sv}, 1) ## @var{q} = size (@var{sv}, 2) ## @end example ## ## The blocks are located so that ## ## @example ## @var{s}(@var{i}(k):@var{i}(k)+@var{p}-1, @var{j}(k):@var{j}(K)+@var{q}-1) = @var{sv}(:,:,k) ## @end example ## ## Multiple blocks corresponding to the same pair of indices are summed, unless ## @var{mode} is "unique", in which case the last of them is used. ## @end deftypefn function s = blksparse (i, j, sv, m = 0, n = 0, mode) persistent chkver = check_version (); if (nargin == 0) i = j = zeros (0, 1); sv = zeros (1, 1, 0); s = class (struct ("i", i, "j", j, "sv", sv, "siz", [0, 0], "bsiz", [1, 1]), "blksparse"); return endif if (nargin < 3 || nargin > 6) print_usage (); endif if (! isvector (i) || ! isvector (j)) error ("blksparse: i, j must be vectors"); elseif (ndims (sv) != 3) error ("blksparse: sv must be a 3D array"); endif if (nargin == 4 && ischar (m)) mode = m; m = 0; elseif (nargin < 6) mode = "sum"; endif if (strcmp (mode, "unique")) summation = false; elseif (strcmp (mode, "sum") || strcmp (mode, "summation")) summation = true; else error ("blksparse: invalid mode: %s", mode); endif if (m == 0) m = max (i); endif if (n == 0) n = max (j); endif siz = [m, n]; ji = [j(:), i(:)]; [ji, fidx, ridx] = unique (ji, "rows"); j = ji(:,1); i = ji(:,2); if (summation) sv = accumdim (ridx, sv, 3, rows (ji)); else sv = sv(:,:,fidx); endif s = struct ("i", i, "j", j, "sv", sv, "siz", siz, "bsiz", size (sv)(1:2)); s = class (s, "blksparse"); endfunction function ok = check_version () ok = compare_versions (version, "3.3.51", ">="); if (! ok) error ("blksparse: can only be used with Octave 3.3.51+"); endif endfunction linear-algebra-2.2.4/inst/@blksparse/PaxHeaders/sparse.m0000644000000000000000000000006215146653315020173 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@blksparse/sparse.m0000644000175000017500000000233315146653315020510 0ustar00philipphilip## Copyright (C) 2010 VZLU Prague ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} sparse (@var{x}) ## Converts a block sparse matrix to (built-in) sparse. ## @end deftypefn function sp = sparse (s) bsiz = s.bsiz; i = repmat (shiftdim (s.i, -2), bsiz); j = repmat (shiftdim (s.j, -2), bsiz); [iofs, jofs] = ndgrid (1:bsiz(1), 1:bsiz(2)); k = ones (1, size (s.sv, 3)); i = sub2ind ([bsiz(1), s.siz(1)], iofs(:,:,k), i); j = sub2ind ([bsiz(2), s.siz(2)], jofs(:,:,k), j); sp = sparse (i(:), j(:), s.sv(:), bsiz(1)*s.siz(1), bsiz(2)*s.siz(2)); endfunction linear-algebra-2.2.4/inst/@blksparse/PaxHeaders/size.m0000644000000000000000000000006215146653315017650 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@blksparse/size.m0000644000175000017500000000156515146653315020173 0ustar00philipphilip## Copyright (C) 2010 VZLU Prague ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} size (@var{x}) ## Returns the size of the matrix. ## @end deftypefn function siz = size (s) siz = s.bsiz .* s.siz; endfunction linear-algebra-2.2.4/inst/@blksparse/PaxHeaders/isreal.m0000644000000000000000000000006215146653315020155 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@blksparse/isreal.m0000644000175000017500000000160115146653315020467 0ustar00philipphilip## Copyright (C) 2010 VZLU Prague ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} isreal (@var{s}) ## Returns true if the array is non-complex. ## @end deftypefn function is = isreal (s) is = isreal (s.sv); endfunction linear-algebra-2.2.4/inst/@blksparse/PaxHeaders/mrdivide.m0000644000000000000000000000006215146653315020501 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@blksparse/mrdivide.m0000644000175000017500000000623315146653315021021 0ustar00philipphilip## Copyright (C) 2010 VZLU Prague ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} mrdivide (@var{x}, @var{y}) ## Performs a left division with a block sparse matrix. ## If @var{y} is a block sparse matrix, it must be either diagonal ## or triangular, and @var{x} must be full. ## If @var{y} is built-in sparse or full, @var{x} is converted ## accordingly, then the built-in division is used. ## @end deftypefn function c = mrdivide (a, b) if (isa (b, "blksparse")) if (issparse (a)) error ("blksparse: sparse / block sparse not implemented"); else c = mrdivide_ms (a, b); endif elseif (issparse (b)) c = sparse (a) / b; else c = full (a) / b; endif endfunction function y = mrdivide_ms (x, s) siz = s.siz; bsiz = s.bsiz; if (bsiz(1) != bsiz(2) || siz(1) != siz(2)) error ("blksparse: can only divide by square matrices with square blocks"); endif ## Check sizes. [xr, xc] = size (x); if (xc != siz(2)*bsiz(2)) gripe_nonconformant (siz.*bsiz, [xr, xc]); endif if (isempty (s) || isempty (x)) y = x; return; endif ## Form blocks. x = reshape (x, xr, bsiz(2), siz(2)); sv = s.sv; si = s.i; sj = s.j; ns = size (sv, 3); n = siz(2); nb = bsiz(2); d = find (si == sj); full_diag = length (d) == n; isdiag = full_diag && ns == n; # block diagonal islower = full_diag && all (si >= sj); # block upper triangular isupper = full_diag && all (si <= sj); # block lower triangular if (isdiag) xx = num2cell (x, [1, 2]); ss = num2cell (sv, [1, 2]); yy = cellfun (@mldivide, ss, xx, "uniformoutput", false); y = cat (3, yy{:}); clear xx ss yy; elseif (isupper) y = zeros (size (x)); ## this is the dot version y(:,:,1) = x(:,:,1) / sv(:,:,1); for j = 2:n k = d(j-1)+1:d(j)-1; xy = blkmm (y(:,:,si(k)), sv(:,:,k)); y(:,:,j) = (x(:,:,j) - sum (xy, 3)) / sv(:,:,d(j)); endfor elseif (islower) y = zeros (size (x)); ## this is the dot version y(:,:,n) = x(:,:,n) / sv(:,:,ns); for j = n-1:-1:1 k = d(j)+1:d(j+1)-1; xy = blkmm (y(:,:,si(k)), sv(:,:,k)); y(:,:,j) = (x(:,:,j) - sum (xy, 3)) / sv(:,:,d(j)); endfor else error ("blksparse: mldivide: matrix must be block triangular or diagonal"); endif ## Narrow blocks. y = reshape (y, xr, bsiz(2)*siz(2)); endfunction function gripe_nonconformant (s1, s2, what = "arguments") error ("Octave:nonconformant-args", ... "nonconformant %s (op1 is %dx%d, op2 is %dx%d)", what, s1, s2); endfunction linear-algebra-2.2.4/inst/@blksparse/PaxHeaders/blksize.m0000644000000000000000000000006215146653315020341 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@blksparse/blksize.m0000644000175000017500000000157015146653315020660 0ustar00philipphilip## Copyright (C) 2010 VZLU Prague ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} blksize (@var{x}) ## Returns the block size of the matrix. ## @end deftypefn function siz = blksize (s) siz = s.siz; endfunction linear-algebra-2.2.4/inst/@blksparse/PaxHeaders/display.m0000644000000000000000000000006215146653315020343 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@blksparse/display.m0000644000175000017500000000245015146653315020660 0ustar00philipphilip## Copyright (C) 2010 VZLU Prague ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} display (@var{x}) ## Displays the block sparse matrix. ## @end deftypefn function display (s) printf ("%s = \n\n", argn); nbl = size (s.sv, 3); header = "Block Sparse Matrix (rows = %d, cols = %d, block = %dx%d, nblocks = %d)\n\n"; printf (header, s.siz .* s.bsiz, s.bsiz, nbl) if (nbl == 0) return; endif rng = [s.i, s.j] * diag (s.bsiz); rng = [rng(:,1) + 1-s.bsiz(1), rng(:,1), rng(:,2) + 1-s.bsiz(2), rng(:,2)]; for k = 1:nbl printf ("(%d:%d, %d:%d) ->\n\n", rng(k,:)); disp (s.sv(:,:,k)); puts ("\n"); endfor endfunction linear-algebra-2.2.4/inst/@blksparse/PaxHeaders/ctranspose.m0000644000000000000000000000006215146653315021057 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@blksparse/ctranspose.m0000644000175000017500000000225515146653315021377 0ustar00philipphilip## Copyright (C) 2010 VZLU Prague ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} ctranspose (@var{x}) ## Returns the conjugate transpose of a block sparse matrix @var{x}. ## @end deftypefn function y = ctranspose (x) #siz = x.siz(2:-1:1); #bsiz = x.bsiz(2:-1:1); [j,idx] = sort (x.i); i = x.j(idx); sv = conj (permute (x.sv(:,:,idx), [2,1,3])); y = blksparse (i, j, sv); endfunction %!test %! r = blksparse ([1,2],[1,2],cat(3,eye(2),[1 2; -2 1])); %! rt = r'; %! assert (full(rt'),full(r)); linear-algebra-2.2.4/inst/@blksparse/PaxHeaders/ismatrix.m0000644000000000000000000000006215146653315020536 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@blksparse/ismatrix.m0000644000175000017500000000160215146653315021051 0ustar00philipphilip## Copyright (C) 2010 VZLU Prague ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} ismatrix (@var{s}) ## Returns true (a blksparse object is a matrix). ## @end deftypefn function yes = ismatrix (s) yes = true; endfunction linear-algebra-2.2.4/inst/@blksparse/PaxHeaders/full.m0000644000000000000000000000006215146653315017640 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@blksparse/full.m0000644000175000017500000000175215146653315020161 0ustar00philipphilip## Copyright (C) 2010 VZLU Prague ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} full (@var{x}) ## Converts a block sparse matrix to full. ## @end deftypefn function f = full (s) f = zeros ([s.bsiz, s.siz]); f(:,:, sub2ind (s.siz, s.i, s.j)) = s.sv; f = reshape (permute (f, [1, 3, 2, 4]), s.bsiz .* s.siz); endfunction linear-algebra-2.2.4/inst/@blksparse/PaxHeaders/minus.m0000644000000000000000000000006215146653315020031 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@blksparse/minus.m0000644000175000017500000000307115146653315020346 0ustar00philipphilip## Copyright (C) 2010 VZLU Prague ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} minus (@var{s1}, @var{s2}) ## Subtract two blksparse objects. ## @end deftypefn function s = minus (s1, s2) if (isa (s1, "blksparse") && isa (s2, "blksparse")) ## Conformance check. siz1 = s1.siz; bsiz1 = s1.bsiz; siz2 = s2.siz; bsiz2 = s2.bsiz; if (bsiz1(2) != bsiz2(1)) gripe_nonconformant (bsiz1, bsiz2, "block sizes"); elseif (siz1(2) != siz2(1)) gripe_nonconformant (bsiz1.*siz1, bsiz2.*siz2); endif ## Stupid & simple. s = blksparse ([s1.i; s2.i], [s1.j; s2.j], cat (3, s1.sv, -s2.sv), siz1(1), siz1(2)); else error ("blksparse: only blksparse - blksparse implemented"); endif endfunction function gripe_nonconformant (s1, s2, what = "arguments") error ("Octave:nonconformant-args", ... "nonconformant %s (op1 is %dx%d, op2 is %dx%d)", what, s1, s2); endfunction linear-algebra-2.2.4/inst/@blksparse/PaxHeaders/subsref.m0000644000000000000000000000006215146653315020347 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@blksparse/subsref.m0000644000175000017500000000400115146653315020656 0ustar00philipphilip## Copyright (C) 2010 VZLU Prague ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} subsref (@var{s}, @var{subs}) ## Index elements from a blksparse object. ## @end deftypefn function ss = subsref (s, subs) if (length (subs) != 1) error ("blksparse: invalid index chain"); endif if (strcmp (subs(1).type, "()")) ind = subs(1).subs; if (length (ind) == 2) idx = make_block_index (ind{1}, s.bsiz(1)); jdx = make_block_index (ind{2}, s.bsiz(2)); ## Use sparse indexing to solve it all. sn = sparse (s.i, s.j, 1:size (s.sv, 3), s.siz(1), s.siz (2)); sn = sn(idx, jdx); [i, j, k] = find (sn); ss = s; ss.i = i; ss.j = j; ss.sv = s.sv(:,:,k); ss.siz = size (sn); else error ("blksparse: linear indexing is not supported"); endif else error ("blksparse: only supports () indexing"); endif endfunction function bi = make_block_index (i, bs) if (strcmp (i, ':')) bi = i; else if (rem (numel (i), bs) == 0) ba = reshape (i, bs, []); bi = ba(1,:); if (any (rem (bi, bs) != 1) || any ((ba != bsxfun (@plus, bi, [0:bs-1].'))(:))) error ("blksparse: index must preserve block structure"); else bi = ceil (bi / bs); endif else error ("blksparse: index must preserve block structure"); endif endif endfunction linear-algebra-2.2.4/inst/@blksparse/PaxHeaders/mldivide.m0000644000000000000000000000006215146653315020473 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@blksparse/mldivide.m0000644000175000017500000000636115146653315021015 0ustar00philipphilip## Copyright (C) 2010 VZLU Prague ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} mldivide (@var{x}, @var{y}) ## Performs a left division with a block sparse matrix. ## If @var{x} is a block sparse matrix, it must be either diagonal ## or triangular, and @var{y} must be full. ## If @var{x} is built-in sparse or full, @var{y} is converted ## accordingly, then the built-in division is used. ## @end deftypefn function c = mldivide (a, b) if (isa (a, "blksparse")) if (issparse (b)) error ("blksparse: block sparse \\ sparse not implemented"); else c = mldivide_sm (a, b); endif elseif (issparse (a)) c = a \ sparse (b); else c = a \ full (b); endif endfunction function y = mldivide_sm (s, x) siz = s.siz; bsiz = s.bsiz; if (bsiz(1) != bsiz(2) || siz(1) != siz(2)) error ("blksparse: can only divide by square matrices with square blocks"); endif ## Check sizes. [xr, xc] = size (x); if (xr != siz(1)*bsiz(1)) gripe_nonconformant (siz.*bsiz, [xr, xc]); endif if (isempty (s) || isempty (x)) y = x; return; endif ## Form blocks. x = reshape (x, bsiz(1), siz(1), xc); x = permute (x, [1, 3, 2]); sv = s.sv; si = s.i; sj = s.j; ns = size (sv, 3); n = siz(1); nb = bsiz(1); d = find (si == sj); full_diag = length (d) == n; isdiag = full_diag && ns == n; # block diagonal islower = full_diag && all (si >= sj); # block upper triangular isupper = full_diag && all (si <= sj); # block lower triangular if (isdiag) xx = num2cell (x, [1, 2]); ss = num2cell (sv, [1, 2]); yy = cellfun (@mldivide, ss, xx, "uniformoutput", false); y = cat (3, yy{:}); clear xx ss yy; elseif (islower) y = x; ## this is the axpy version for j = 1:n-1 y(:,:,j) = sv(:,:,d(j)) \ y(:,:,j); k = d(j)+1:d(j+1)-1; xy = y(:,:,j*ones (1, length (k))); y(:,:,si(k)) -= blkmm (sv(:,:,k), xy); endfor y(:,:,n) = sv(:,:,ns) \ y(:,:,n); elseif (isupper) y = x; ## this is the axpy version for j = n:-1:2 y(:,:,j) = sv(:,:,d(j)) \ y(:,:,j); k = d(j-1)+1:d(j)-1; xy = y(:,:,j*ones (1, length (k))); y(:,:,si(k)) -= blkmm (sv(:,:,k), xy); endfor y(:,:,1) = sv(:,:,1) \ y(:,:,1); else error ("blksparse: mldivide: matrix must be block triangular or diagonal"); endif ## Narrow blocks. y = permute (y, [1, 3, 2]); y = reshape (y, bsiz(1)*siz(1), xc); endfunction function gripe_nonconformant (s1, s2, what = "arguments") error ("Octave:nonconformant-args", ... "nonconformant %s (op1 is %dx%d, op2 is %dx%d)", what, s1, s2); endfunction linear-algebra-2.2.4/inst/@blksparse/PaxHeaders/mtimes.m0000644000000000000000000000006215146653315020174 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@blksparse/mtimes.m0000644000175000017500000000627015146653315020515 0ustar00philipphilip## Copyright (C) 2010 VZLU Prague ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} mtimes (@var{x}, @var{y}) ## Multiplies a block sparse matrix with a full matrix, or two block sparse ## matrices. Multiplication of block sparse * sparse is not implemented. ## If one of arguments is a scalar, it's a scalar multiply. ## @end deftypefn function c = mtimes (a, b) if (isa (a, "blksparse")) if (isa (b, "blksparse")) c = mtimes_ss (a, b); else c = mtimes_sm (a, b); endif elseif (isa (b, "blksparse")) c = mtimes_ms (a, b); else error ("blksparse: invalid arguments to mtimes"); endif endfunction function y = mtimes_sm (s, x) if (isscalar (x)) y = s; y.sv *= x; return; elseif (issparse (x)) error ("blksparse * sparse not implemented."); endif siz = s.siz; bsiz = s.bsiz; ## Check sizes. [xr, xc] = size (x); if (xr != siz(2)*bsiz(2)) gripe_nonconformant (siz.*bsiz, [xr, xc]); endif ## Form blocks. x = reshape (x, bsiz(2), siz(2), xc); x = permute (x, [1, 3, 2]); ## Scatter. xs = x(:,:,s.j); ## Multiply. ys = blkmm (s.sv, xs); ## Gather. y = accumdim (s.i, ys, 3, siz(1)); y = permute (y, [1, 3, 2]); ## Narrow blocks. y = reshape (y, bsiz(1)*siz(1), xc); endfunction function y = mtimes_ms (x, s) if (isscalar (x)) y = s; y.sv *= x; return; elseif (issparse (x)) error ("sparse * blksparse not implemented."); endif siz = s.siz; bsiz = s.bsiz; ## Check sizes. [xr, xc] = size (x); if (xc != siz(1)*bsiz(1)) gripe_nonconformant ([xr, xc], siz.*bsiz); endif ## Form blocks. x = reshape (x, xr, bsiz(2), siz(2)); ## Scatter. xs = x(:,:,s.i); ## Multiply. ys = blkmm (xs, s.sv); ## Gather. y = accumdim (s.j, ys, 3, siz(2)); ## Narrow blocks. y = reshape (y, xr, bsiz(2)*siz(2)); endfunction function s = mtimes_ss (s1, s2) ## Conformance check. siz1 = s1.siz; bsiz1 = s1.bsiz; siz2 = s2.siz; bsiz2 = s2.bsiz; if (bsiz1(2) != bsiz2(1)) gripe_nonconformant (bsiz1, bsiz2, "block sizes"); elseif (siz1(2) != siz2(1)) gripe_nonconformant (bsiz1.*siz1, bsiz2.*siz2); endif ## Hardcore hacks, man! ss = sparse (s1.i, s1.j, 1:length (s1.i), "unique"); ss = ss(:,s2.i); [i, j, k] = find (ss); sv = blkmm (s1.sv(:,:,k), s2.sv(:,:,j)); j = s2.j(j); s = blksparse (i, j, sv, siz1(1), siz2(2)); endfunction function gripe_nonconformant (s1, s2, what = "arguments") error ("Octave:nonconformant-args", ... "nonconformant %s (op1 is %dx%d, op2 is %dx%d)", what, s1, s2); endfunction linear-algebra-2.2.4/inst/@blksparse/PaxHeaders/uminus.m0000644000000000000000000000006215146653315020216 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@blksparse/uminus.m0000644000175000017500000000161615146653315020536 0ustar00philipphilip## Copyright (C) 2010 VZLU Prague ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} uminus (@var{x}) ## Returns the negative of a block sparse matrix @var{x}. ## @end deftypefn function y = uminus (x) y = x; y.sv = -x.sv; endfunction linear-algebra-2.2.4/inst/@blksparse/PaxHeaders/uplus.m0000644000000000000000000000006215146653315020046 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@blksparse/uplus.m0000644000175000017500000000170715146653315020367 0ustar00philipphilip## Copyright (C) 2010 VZLU Prague ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} uplus (@var{x}) ## Returns the unary plus of a block sparse matrix @var{x}. ## Effectively the matrix itself, except signs of zeros. ## @end deftypefn function y = uplus (x) y = x; y.sv = +x.sv; endfunction linear-algebra-2.2.4/inst/@blksparse/PaxHeaders/plus.m0000644000000000000000000000006215146653315017661 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@blksparse/plus.m0000644000175000017500000000306115146653315020175 0ustar00philipphilip## Copyright (C) 2010 VZLU Prague ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} plus (@var{s1}, @var{s2}) ## Add two blksparse objects. ## @end deftypefn function s = plus (s1, s2) if (isa (s1, "blksparse") && isa (s2, "blksparse")) ## Conformance check. siz1 = s1.siz; bsiz1 = s1.bsiz; siz2 = s2.siz; bsiz2 = s2.bsiz; if (bsiz1(2) != bsiz2(1)) gripe_nonconformant (bsiz1, bsiz2, "block sizes"); elseif (siz1(2) != siz2(1)) gripe_nonconformant (bsiz1.*siz1, bsiz2.*siz2); endif ## Stupid & simple. s = blksparse ([s1.i; s2.i], [s1.j; s2.j], cat (3, s1.sv, s2.sv), siz1(1), siz1(2)); else error ("blksparse: only blksparse + blksparse implemented"); endif endfunction function gripe_nonconformant (s1, s2, what = "arguments") error ("Octave:nonconformant-args", ... "nonconformant %s (op1 is %dx%d, op2 is %dx%d)", what, s1, s2); endfunction linear-algebra-2.2.4/inst/@blksparse/PaxHeaders/issparse.m0000644000000000000000000000006215146653315020527 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@blksparse/issparse.m0000644000175000017500000000161315146653315021044 0ustar00philipphilip## Copyright (C) 2010 VZLU Prague ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} issparse (@var{s}) ## Returns true since a blksparse is sparse by definition. ## @end deftypefn function yes = issparse (s) yes = true; endfunction linear-algebra-2.2.4/inst/@blksparse/PaxHeaders/transpose.m0000644000000000000000000000006215146653315020714 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/@blksparse/transpose.m0000644000175000017500000000201015146653315021221 0ustar00philipphilip## Copyright (C) 2010 VZLU Prague ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} transpose (@var{x}) ## Returns the transpose of a block sparse matrix @var{x}. ## @end deftypefn function y = transpose (x) y.siz = x.siz(2:-1:1); y.bsiz = x.bsiz(2:-1:1); [y.j,idx] = sort (x.i); y.i = x.j(idx); y.sv = permute (x.sv(:,:,idx), [2,1,3]); endfunction linear-algebra-2.2.4/inst/PaxHeaders/funm.m0000644000000000000000000000006215146653315015555 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/funm.m0000644000175000017500000000764015146653315016100 0ustar00philipphilip## Copyright (C) 2000-2019 P.R. Nienhuis ## Copyright (C) 2001 Paul Kienzle ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{B} =} funm (@var{A}, @var{F}) ## Compute matrix equivalent of function F; F can be a function name or ## a function handle and A must be a square matrix. ## ## For trigonometric and hyperbolic functions, @code{thfm} is automatically ## invoked as that is based on @code{expm} and diagonalization is avoided. ## For other functions diagonalization is invoked, which implies that ## -depending on the properties of input matrix @var{A}- the results ## can be very inaccurate @emph{without any warning}. For easy diagonizable and ## stable matrices the results of funm will be sufficiently accurate. ## ## Note that you should not use funm for 'sqrt', 'log' or 'exp'; instead ## use sqrtm, logm and expm as these are more robust. ## ## Examples: ## ## @example ## B = funm (A, sin); ## (Compute matrix equivalent of sin() ) ## @end example ## ## @example ## function bk1 = besselk1 (x) ## bk1 = besselk(1, x); ## endfunction ## B = funm (A, besselk1); ## (Compute matrix equivalent of bessel function K1(); ## a helper function is needed here to convey extra ## arguments for besselk() ) ## @end example ## ## Note that a much improved funm.m function has been implemented in Octave ## 11.1.0, so funm.m will be removed from the linear-algebra package if that ## is installed in Octave 11+. ## ## @seealso{thfm, expm, logm, sqrtm} ## @end deftypefn function B = funm (A, name) persistent thfuncs = {"cos", "sin", "tan", "sec", "csc", "cot", ... "cosh", "sinh", "tanh", "sech", "csch", "coth", ... "acos", "asin", "atan", "asec", "acsc", "acot", ... "acosh", "asinh", "atanh", "asech", "acsch", "acoth", ... } ## Function handle supplied? try ishndl = isstruct (functions (name)); fname = functions (name).function; name = '-'; catch ishndl = 0; fname = ' '; end_try_catch ## Check input if (nargin < 2 || (! (ischar (name) || ishndl)) || ischar (A)) print_usage (); elseif (! issquare (A)) error ("funm.m: square matrix expected for first argument\n"); endif if (! isempty (find (ismember ({fname, name}, thfuncs)))) ## Use more robust thfm () if (ishndl) name = fname; endif B = thfm (A, name); else ## Simply invoke eigenvalues. Note: risk for repeated eigenvalues!! ## Modeled after suggestion by N. Higham (based on R. Davis, 2007) ## FIXME Do we need automatic setting of TOL? tol = 1.e-15; [V, D] = eig (A + tol * randn (size(A))); D = diag (feval (name, diag(D))); B = V * D / V; ## The diagonalization generates complex values anyway, even for symmetric ## matrices, due to the tolerance trick after Higham/Davis applied above. ## Return real part if all abs(imaginary values) are < eps if (! any (abs (imag(B)(:)) > eps)) B = real (B); endif endif endfunction %!function b = fsin (a) %! b = sin (a); %!endfunction %% test helper function to avoid thfm; but use thfm results as reference %!test %! mtx = randn (100); %! assert (funm (mtx, "fsin"), thfm (mtx, "sin"), 1e-9) linear-algebra-2.2.4/inst/PaxHeaders/rotv.m0000644000000000000000000000006215146653315015602 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/rotv.m0000644000175000017500000000454115146653315016122 0ustar00philipphilip## Copyright (C) 2002 Etienne Grossmann ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn{Function File} {@var{r} = } rotv ( v, ang ) ## @cindex ## The functionrotv calculates a Matrix of rotation about @var{v} w/ angle |v| ## r = rotv(v [,ang]) ## ## Returns the rotation matrix w/ axis v, and angle, in radians, norm(v) or ## ang (if present). ## ## rotv(v) == w'*w + cos(a) * (eye(3)-w'*w) - sin(a) * crossmat(w) ## ## where a = norm (v) and w = v/a. ## ## v and ang may be vertically stacked : If 'v' is 2x3, then ## rotv( v ) == [rotv(v(1,:)); rotv(v(2,:))] ## ## @seealso{rotparams, rota, rot} ## ## @end deftypefn function r = rotv(v ,ang) if nargin > 1 v = v.*((ang(:)./sqrt(sum(v'.^2))')*ones(1,3)); end ## For checking only ## v00 = v ; ## static toto = floor(rand(1)*100) ; ## toto a = sqrt(sum(v'.^2))' ; oka = find(a!=0); if all(size(oka)), v(oka,:) = v(oka,:)./(a(oka)*ones(1,3)) ; end ## ca = cos(a); ## sa = sin(a); N = size(v,1) ; N3 = 3*N ; r = (reshape( v', N3,1 )*ones(1,3)).*kron(v,ones(3,1)) ; r += kron(cos(a),ones(3,3)) .* (kron(ones(N,1),eye(3))-r) ; ## kron(cos(a),ones(3,3)) .* (kron(ones(N,1),eye(3))-r0) ## cos(a) tmp = zeros(N3,3) ; tmp( 2:3:N3,1 ) = v(:,3) ; tmp( 1:3:N3,2 ) = -v(:,3) ; tmp( 3:3:N3,1 ) = -v(:,2) ; tmp( 1:3:N3,3 ) = v(:,2) ; tmp( 2:3:N3,3 ) = -v(:,1) ; tmp( 3:3:N3,2 ) = v(:,1) ; ## keyboard r -= kron(sin(a),ones(3)) .* tmp ; endfunction ## For checking only ## r2 = zeros(N3,3) ; ## for i=1:size(v,1), ## v0 = v00(i,:); ## t = norm(v0); ## if t, v0 = v0/t; end; ## r2(3*i-2:3*i,:) = v0'*v0 + cos(t)*(eye(3)-v0'*v0) + -sin(t)*[0, -v0(3), v0(2);v0(3), 0, -v0(1);-v0(2), v0(1), 0]; ## end ## max(abs(r2(:)-r(:))) linear-algebra-2.2.4/inst/PaxHeaders/thfm.m0000644000000000000000000000006215146653315015546 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/thfm.m0000644000175000017500000000773615146653315016077 0ustar00philipphilip## Copyright (C) 2001 Rolf Fabian ## Copyright (C) 2001 Paul Kienzle ## Copyright (C) 2011 Philip Nienhuis ## Copyright (C) 2011 CarnĂ« Draug ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn{Function File} {@var{y} =} thfm (@var{x}, @var{mode}) ## Trigonometric/hyperbolic functions of square matrix @var{x}. ## ## @var{mode} must be the name of a function. Valid functions are 'sin', 'cos', ## 'tan', 'sec', 'csc', 'cot' and all their inverses and/or hyperbolic variants, ## and 'sqrt', 'log' and 'exp'. ## ## The code @code{thfm (x, 'cos')} calculates matrix cosinus @emph{even if} input ## matrix @var{x} is @emph{not} diagonalizable. ## ## @emph{Important note}: ## This algorithm does @emph{not} use an eigensystem similarity transformation. It ## maps the @var{mode} functions to functions of @code{expm}, @code{logm} and ## @code{sqrtm}, which are known to be robust with respect to non-diagonalizable ## ('defective') @var{x}. ## ## @seealso{funm} ## @end deftypefn function y = thfm (x,M) ## minimal arg check only if ( nargin != 2 || !ischar (M) || ischar (x) ) print_usage; endif ## look for known functions of sqrt, log, exp I = eye (size (x)); switch (M) case {'cos'} if (isreal(x)) y = real( expm( i*x ) ); else y = ( expm( i*x ) + expm( -i*x ) ) / 2; endif case {'sin'} if (isreal(x)) y = imag( expm( i*x ) ); else y = ( expm( i*x ) - expm( -i*x ) ) / (2*i); endif case {'tan'} if (isreal(x)) t = expm( i*x ); y = imag(t)/real(t); else t = expm( -2*i*x ); y = -i*(I-t)/(I+t); endif case {'cot'} if (isreal(x)) t = expm( i*x ); y = real(t)/imag(t); else t = expm( -2*i*x ); y = i*(I+t)/(I-t); endif case {'sec'} if (isreal(x)) y = inv( real(expm(i*x)) ); else y = inv( expm(i*x)+expm(-i*x) )*2 ; endif case {'csc'} if (isreal(x)) y = inv( imag(expm(i*x)) ); else y = inv( expm(i*x)-expm(-i*x) )*2i; endif case {'log'} y = logm(x); case {'exp'} y = expm(x); case {'cosh'} y = ( expm(x)+expm(-x) )/2; case {'sinh'} y = ( expm(x)-expm(-x) )/2; case {'tanh'} t = expm( -2*x ); y = (I - t)/(I + t); case {'coth'} t = expm( -2*x ); y = (I + t)/(I - t); case {'sech'} y = 2 * inv( expm(x) + expm(-x) ); case {'csch'} y = 2 * inv( expm(x) - expm(-x) ); case {'asin'} y = -i * logm( i*x + sqrtm(I - x*x) ); case {'acos'} y = i * logm( x - i*sqrtm(I - x*x) ); case {'atan'} y = -i/2 * logm( (I + i*x)/(I - i*x) ); case {'acot'} y = i/2 * logm( (I + i*x)/(i*x - I) ); case {'asec'} y = i * logm( ( I - sqrtm(I - x*x) ) / x ); case {'acsc'} y = -i * logm( i*( I + sqrtm(I - x*x) ) / x ); case {'sqrt'} y = sqrtm(x); case {'asinh'} y = logm( x + sqrtm (x*x + I) ); case {'acosh'} y = logm( x + sqrtm (x*x - I) ); case {'atanh'} y = logm( (I + x)/(I - x) ) / 2; case {'acoth'} y = logm( (I + x)/(x - I) ) / 2; case {'asech'} y = logm( (I + sqrtm (I - x*x)) / x ); case {'acsch'} y = logm( (I + sqrtm (I + x*x)) / x ); otherwise error ("thfm doesn't support function %s - try to use funm instead.", M); endswitch endfunction linear-algebra-2.2.4/inst/PaxHeaders/nmf_bpas.m0000644000000000000000000000006215146653315016375 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/nmf_bpas.m0000644000175000017500000006321715146653315016722 0ustar00philipphilip## Copyright (c) 2012 by Jingu Kim and Haesun Park ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{W}, @var{H}, @var{iter}, @var{HIS}] = } nmf_bpas (@var{A}, @var{k}) ## Nonnegative Matrix Factorization by Alternating Nonnegativity Constrained Least Squares ## using Block Principal Pivoting/Active Set method. ## ## This function solves one the following problems: given @var{A} and @var{k}, find @var{W} and @var{H} such that ## ## @group ## (1) minimize 1/2 * || @var{A}-@var{W}@var{H} ||_F^2 ## ## (2) minimize 1/2 * ( || @var{A}-@var{W}@var{H} ||_F^2 + alpha * || @var{W} ||_F^2 + beta * || @var{H} ||_F^2 ) ## ## (3) minimize 1/2 * ( || @var{A}-@var{W}@var{H} ||_F^2 + alpha * || @var{W} ||_F^2 + beta * (sum_(i=1)^n || @var{H}(:,i) ||_1^2 ) ) ## @end group ## ## where @var{W}>=0 and @var{H}>=0 elementwise. ## The input arguments are @var{A} : Input data matrix (m x n) and @var{k} : Target low-rank. ## ## ## @strong{Optional Inputs} ## @table @samp ## @item Type ## Default is 'regularized', which is recommended for quick application testing unless 'sparse' or 'plain' is explicitly needed. If sparsity is needed for 'W' factor, then apply this function for the transpose of 'A' with formulation (3). Then, exchange 'W' and 'H' and obtain the transpose of them. Imposing sparsity for both factors is not recommended and thus not included in this software. ## @table @asis ## @item 'plain' ## to use formulation (1) ## @item 'regularized' ## to use formulation (2) ## @item 'sparse' ## to use formulation (3) ## @end table ## ## @item NNLSSolver ## Default is 'bp', which is in general faster. ## @table @asis ## @item 'bp' ## to use the algorithm in [1] ## @item 'as' ## to use the algorithm in [2] ## @end table ## ## @item Alpha ## Parameter alpha in the formulation (2) or (3). Default is the average of all elements in A. No good justfication for this default value, and you might want to try other values. ## @item Beta ## Parameter beta in the formulation (2) or (3). ## Default is the average of all elements in A. No good justfication for this default value, and you might want to try other values. ## @item MaxIter ## Maximum number of iterations. Default is 100. ## @item MinIter ## Minimum number of iterations. Default is 20. ## @item MaxTime ## Maximum amount of time in seconds. Default is 100,000. ## @item Winit ## (m x k) initial value for W. ## @item Hinit ## (k x n) initial value for H. ## @item Tol ## Stopping tolerance. Default is 1e-3. If you want to obtain a more accurate solution, decrease TOL and increase MAX_ITER at the same time. ## @item Verbose ## If present the function will show information during the calculations. ## @end table ## ## @strong{Outputs} ## @table @samp ## @item W ## Obtained basis matrix (m x k) ## @item H ## Obtained coefficients matrix (k x n) ## @item iter ## Number of iterations ## @item HIS ## If present the history of computation is returned. ## @end table ## ## Usage Examples: ## @example ## nmf_bpas (A,10) ## nmf_bpas (A,20,'verbose') ## nmf_bpas (A,30,'verbose','nnlssolver','as') ## nmf_bpas (A,5,'verbose','type','sparse') ## nmf_bpas (A,60,'verbose','type','plain','Winit',rand(size(A,1),60)) ## nmf_bpas (A,70,'verbose','type','sparse','nnlssolver','bp','alpha',1.1,'beta',1.3) ## @end example ## ## References: ## [1] For using this software, please cite:@* ## Jingu Kim and Haesun Park, Toward Faster Nonnegative Matrix Factorization: A New Algorithm and Comparisons,@* ## In Proceedings of the 2008 Eighth IEEE International Conference on Data Mining (ICDM'08), 353-362, 2008@* ## [2] If you use 'nnls_solver'='as' (see below), please cite:@* ## Hyunsoo Kim and Haesun Park, Nonnegative Matrix Factorization Based @* ## on Alternating Nonnegativity Constrained Least Squares and Active Set Method, @* ## SIAM Journal on Matrix Analysis and Applications, 2008, 30, 713-730 ## ## Check original code at @url{http://www.cc.gatech.edu/~jingu} ## ## @seealso{nmf_pg} ## @end deftypefn ## 2015 - Modified and adapted to Octave 4.0 by ## Juan Pablo Carbajal # TODO # - Format code. # - Vectorize loops. function [W, H, iter, varargout] = nmf_bpas (A, k , varargin) page_screen_output (0, "local"); [m,n] = size(A); ST_RULE = 1; # --- Parse arguments --- # isnummatrix = @(x) ismatrix (x) & isnumeric (x); parser = inputParser (); parser.FunctionName = "nmf_bpas"; parser.addParamValue ('Winit', rand(m,k), isnummatrix); parser.addParamValue ('Hinit', rand(k,n), isnummatrix); parser.addParamValue ('Tol', 1e-3, @(x)x>0); parser.addParamValue ('Alpha', mean (A(:)), @(x)x>=0); parser.addParamValue ('Beta', mean (A(:)), @(x)x>=0); parser.addParamValue ('MaxIter', 100, @(x)x>0); parser.addParamValue ('MaxTime', 1e3, @(x)x>0); parser.addSwitch ('Verbose'); val_type = @(x,c) ischar (x) && any (strcmpi (x,c)); parser.addParamValue ('Type', 'regularized', ... @(x)val_type (x,{'regularized', 'sparse','plain'})); parser.addParamValue ('NNLSSolver', 'bp', @(x)val_type (x,{'bp', 'as'})); parser.parse(varargin{:}); % Default configuration par.m = m; par.n = n; par.type = parser.Results.Type; par.nnls_solver = parser.Results.NNLSSolver; par.alpha = parser.Results.Alpha; par.beta = parser.Results.Beta; par.max_iter = parser.Results.MaxIter; par.min_iter = 20; par.max_time = parser.Results.MaxTime; par.tol = parser.Results.Tol; par.verbose = parser.Results.Verbose; W = parser.Results.Winit; H = parser.Results.Hinit; # If the user asks for the 4th argument, it means they want the history # of the calculations. par.collectInfo = nargout > 3; clear parser val_type isnummatrix # ------------------- --- # ### PARSING TYPE # TODO add callbacks here to use during main loop. See [1] % for regularized/sparse case salphaI = sqrt (par.alpha) * eye (k); zerokm = zeros (k,m); if ( strcmpi (par.type, 'regularized') ) sbetaI = sqrt (par.beta) * eye (k); zerokn = zeros (k,n); elseif ( strcmpi (par.type, 'sparse') ) sbetaE = sqrt (par.beta) * ones (1,k); betaI = par.beta * ones (k,k); zero1n = zeros (1,n); endif ### if (par.collectInfo) % collect information for analysis/debugging [gradW, gradH] = getGradient (A,W,H,par.type,par.alpha,par.beta); initGrNormW = norm (gradW,'fro'); initGrNormH = norm (gradH,'fro'); initNorm = norm (A,'fro'); numSC = 3; initSCs = zeros (numSC,1); for j = 1:numSC initSCs(j) = ... getInitCriterion (j,A,W,H,par.type,par.alpha,par.beta,gradW,gradH); endfor ver.initGrNormW = initGrNormW; ver.initGrNormH = initGrNormH; ver.initNorm = initNorm; ver.SC1 = initSCs(1); ver.SC2 = initSCs(2); ver.SC3 = initSCs(3); ver.W_density = length (find (W>0)) / (m * k); ver.H_density = length (find (H>0)) / (n * k); tPrev = cputime; if (par.verbose) disp (ver); endif endif # Verbosity if (par.verbose) display (par); endif tStart = cputime; tTotal = 0; initSC = getInitCriterion (ST_RULE,A,W,H,par.type,par.alpha,par.beta); SCconv = 0; SC_COUNT = 3; #TODO: [1] Replace with callbacks avoid switching each time for iter = 1:par.max_iter switch par.type case 'plain' [H,gradHX,subIterH] = nnlsm (W,A,H,par.nnls_solver); [W,gradW,subIterW] = nnlsm (H',A',W',par.nnls_solver); extra_term = 0; case 'regularized' [H,gradHX,subIterH] = nnlsm ([W;sbetaI],[A;zerokn],H,par.nnls_solver); [W,gradW,subIterW] = nnlsm ([H';salphaI],[A';zerokm],W',par.nnls_solver); extra_term = par.beta * H; case 'sparse' [H,gradHX,subIterH] = nnlsm ([W;sbetaE],[A;zero1n],H,par.nnls_solver); [W,gradW,subIterW] = nnlsm ([H';salphaI],[A';zerokm],W',par.nnls_solver); extra_term = betaI * H; endswitch gradH = ( W * W' ) * H - W * A + extra_term; W = W'; gradW = gradW'; if (par.collectInfo) % collect information for analysis/debugging elapsed = cputime - tPrev; tTotal = tTotal + elapsed; idx = iter+1; ver.iter(idx) = iter; ver.elapsed(idx) = elapsed; ver.tTotal(idx) = tTotal; ver.subIterW(idx) = subIterW; ver.subIterH(idx) = subIterH; ver.relError(idx) = norm (A - W * H,'fro') / initNorm; ver.SC1(idx) = ... getStopCriterion (1,A,W,H,par.type,par.alpha,par.beta,gradW,gradH) / initSCs(1); ver.SC2(idx) = ... getStopCriterion (2,A,W,H,par.type,par.alpha,par.beta,gradW,gradH) / initSCs(2); ver.SC3(idx) = ... getStopCriterion (3,A,W,H,par.type,par.alpha,par.beta,gradW,gradH) / initSCs(3); ver.W_density(idx) = length (find (W>0)) / (m * k); ver.H_density(idx) = length (find (H>0)) / (n * k); if (par.verbose) toshow = structfun (@(x)x(end), ver, "UniformOutput", false); display (toshow); endif tPrev = cputime; endif if (iter > par.min_iter) SC = getStopCriterion (ST_RULE,A,W,H,par.type,par.alpha,par.beta,gradW,gradH); if ( ( par.collectInfo && tTotal > par.max_time) || ... (~par.collectInfo && cputime-tStart > par.max_time ) ) printf ("Stop: maximum total time reached.\n"); break; elseif ( SC / initSC <= par.tol ) SCconv = SCconv + 1; if (SCconv >= SC_COUNT) printf ("Stop: tolerance reached.\n"); break; endif else SCconv = 0; endif endif endfor [m,n] = size (A); norm2 = sqrt (sum (W.^2,1)); toNormalize = norm2 > eps; W(:,toNormalize) = W(:,toNormalize) ./ norm2(toNormalize); H(toNormalize,:) = H(toNormalize,:) .* norm2(toNormalize)'; final.iterations = iter; if (par.collectInfo) final.elapsed_total = tTotal; else final.elapsed_total = cputime - tStart; endif final.relative_error = norm (A - W * H,'fro') / norm(A,'fro'); final.W_density = length (find (W>0)) / (m * k); final.H_density = length(find (H>0)) / (n * k); if (par.verbose) display (final); endif if (par.collectInfo) varargout{1} = ver; endif endfunction ### Done till here Wed Mar 18 2015 %------------------- % Utility Functions %------------------- function retVal = getInitCriterion(stopRule,A,W,H,type,alpha,beta,gradW,gradH) % STOPPING_RULE : 1 - Normalized proj. gradient % 2 - Proj. gradient % 3 - Delta by H. Kim % 0 - None (want to stop by MAX_ITER or MAX_TIME) if nargin~=9 [gradW,gradH] = getGradient(A,W,H,type,alpha,beta); end [m,k]=size(W);, [k,n]=size(H);, numAll=(m*k)+(k*n); switch stopRule case 1 retVal = norm([gradW; gradH'],'fro')/numAll; case 2 retVal = norm([gradW; gradH'],'fro'); case 3 retVal = getStopCriterion(3,A,W,H,type,alpha,beta,gradW,gradH); case 0 retVal = 1; end endfunction function retVal = getStopCriterion(stopRule,A,W,H,type,alpha,beta,gradW,gradH) % STOPPING_RULE : 1 - Normalized proj. gradient % 2 - Proj. gradient % 3 - Delta by H. Kim % 0 - None (want to stop by MAX_ITER or MAX_TIME) if nargin~=9 [gradW,gradH] = getGradient(A,W,H,type,alpha,beta); end switch stopRule case 1 pGradW = gradW(gradW<0|W>0); pGradH = gradH(gradH<0|H>0); pGrad = [gradW(gradW<0|W>0); gradH(gradH<0|H>0)]; pGradNorm = norm(pGrad); retVal = pGradNorm/length(pGrad); case 2 pGradW = gradW(gradW<0|W>0); pGradH = gradH(gradH<0|H>0); pGrad = [gradW(gradW<0|W>0); gradH(gradH<0|H>0)]; retVal = norm(pGrad); case 3 resmat=min(H,gradH); resvec=resmat(:); resmat=min(W,gradW); resvec=[resvec; resmat(:)]; deltao=norm(resvec,1); %L1-norm num_notconv=length(find(abs(resvec)>0)); retVal=deltao/num_notconv; case 0 retVal = 1e100; end endfunction function [gradW,gradH] = getGradient(A,W,H,type,alpha,beta) switch type case 'plain' gradW = W*(H*H') - A*H'; gradH = (W'*W)*H - W'*A; case 'regularized' gradW = W*(H*H') - A*H' + alpha*W; gradH = (W'*W)*H - W'*A + beta*H; case 'sparse' k=size(W,2); betaI = beta*ones(k,k); gradW = W*(H*H') - A*H' + alpha*W; gradH = (W'*W)*H - W'*A + betaI*H; end endfunction function [X,grad,iter] = nnlsm(A,B,init,solver) switch solver case 'bp' [X,grad,iter] = nnlsm_blockpivot(A,B,0,init); case 'as' [X,grad,iter] = nnlsm_activeset(A,B,1,0,init); end endfunction function [ X,Y,iter,success ] = nnlsm_activeset( A, B, overwrite, isInputProd, init) % Nonnegativity Constrained Least Squares with Multiple Righthand Sides % using Active Set method % % This software solves the following problem: given A and B, find X such that % minimize || AX-B ||_F^2 where X>=0 elementwise. % % Reference: % Charles L. Lawson and Richard J. Hanson, Solving Least Squares Problems, % Society for Industrial and Applied Mathematics, 1995 % M. H. Van Benthem and M. R. Keenan, % Fast Algorithm for the Solution of Large-scale Non-negativity-constrained Least Squares Problems, % J. Chemometrics 2004; 18: 441-450 % % Written by Jingu Kim (jingu@cc.gatech.edu) % School of Computational Science and Engineering, % Georgia Institute of Technology % % Last updated Feb-20-2010 % % % A : input matrix (m x n) (by default), or A'*A (n x n) if isInputProd==1 % B : input matrix (m x k) (by default), or A'*B (n x k) if isInputProd==1 % overwrite : (optional, default:0) if turned on, unconstrained least squares solution is computed in the beginning % isInputProd : (optional, default:0) if turned on, use (A'*A,A'*B) as input instead of (A,B) % init : (optional) initial value for X % % X : the solution (n x k) % Y : A'*A*X - A'*B where X is the solution (n x k) % iter : number of iterations % success : 1 for success, 0 for failure. % Failure could only happen on a numericall very ill-conditioned problem. if nargin<3, overwrite=0;, end if nargin<4, isInputProd=0;, end if isInputProd AtA=A;,AtB=B; else AtA=A'*A;, AtB=A'*B; end [n,k]=size(AtB); MAX_ITER = n*5; % set initial feasible solution if overwrite [X,iter] = solveNormalEqComb(AtA,AtB); PassSet = (X > 0); NotOptSet = any(X<0); else if nargin<5 X = zeros(n,k); PassSet = false(n,k); NotOptSet = true(1,k); else X = init; PassSet = (X > 0); NotOptSet = any(X<0); end iter = 0; end Y = zeros(n,k); Y(:,~NotOptSet)=AtA*X(:,~NotOptSet) - AtB(:,~NotOptSet); NotOptCols = find(NotOptSet); bigIter = 0;, success=1; while(~isempty(NotOptCols)) bigIter = bigIter+1; if ((MAX_ITER >0) && (bigIter > MAX_ITER)) % set max_iter for ill-conditioned (numerically unstable) case success = 0;, bigIter, break end % find unconstrained LS solution for the passive set Z = zeros(n,length(NotOptCols)); [ Z,subiter ] = solveNormalEqComb(AtA,AtB(:,NotOptCols),PassSet(:,NotOptCols)); iter = iter + subiter; %Z(abs(Z)<1e-12) = 0; % One can uncomment this line for numerical stability. InfeaSubSet = Z < 0; InfeaSubCols = find(any(InfeaSubSet)); FeaSubCols = find(all(~InfeaSubSet)); if ~isempty(InfeaSubCols) % for infeasible cols ZInfea = Z(:,InfeaSubCols); InfeaCols = NotOptCols(InfeaSubCols); Alpha = zeros(n,length(InfeaSubCols));, Alpha(:,:) = Inf; InfeaSubSet(:,InfeaSubCols); [i,j] = find(InfeaSubSet(:,InfeaSubCols)); InfeaSubIx = sub2ind(size(Alpha),i,j); if length(InfeaCols) == 1 InfeaIx = sub2ind([n,k],i,InfeaCols * ones(length(j),1)); else InfeaIx = sub2ind([n,k],i,InfeaCols(j)'); end Alpha(InfeaSubIx) = X(InfeaIx)./(X(InfeaIx)-ZInfea(InfeaSubIx)); [minVal,minIx] = min(Alpha); Alpha(:,:) = repmat(minVal,n,1); X(:,InfeaCols) = X(:,InfeaCols)+Alpha.*(ZInfea-X(:,InfeaCols)); IxToActive = sub2ind([n,k],minIx,InfeaCols); X(IxToActive) = 0; PassSet(IxToActive) = false; end if ~isempty(FeaSubCols) % for feasible cols FeaCols = NotOptCols(FeaSubCols); X(:,FeaCols) = Z(:,FeaSubCols); Y(:,FeaCols) = AtA * X(:,FeaCols) - AtB(:,FeaCols); %Y( abs(Y)<1e-12 ) = 0; % One can uncomment this line for numerical stability. NotOptSubSet = (Y(:,FeaCols) < 0) & ~PassSet(:,FeaCols); NewOptCols = FeaCols(all(~NotOptSubSet)); UpdateNotOptCols = FeaCols(any(NotOptSubSet)); if ~isempty(UpdateNotOptCols) [minVal,minIx] = min(Y(:,UpdateNotOptCols).*~PassSet(:,UpdateNotOptCols)); PassSet(sub2ind([n,k],minIx,UpdateNotOptCols)) = true; end NotOptSet(NewOptCols) = false; NotOptCols = find(NotOptSet); end end endfunction function [ X,Y,iter,success ] = nnlsm_blockpivot( A, B, isInputProd, init ) % Nonnegativity Constrained Least Squares with Multiple Righthand Sides % using Block Principal Pivoting method % % This software solves the following problem: given A and B, find X such that % minimize || AX-B ||_F^2 where X>=0 elementwise. % % Reference: % Jingu Kim and Haesun Park, Toward Faster Nonnegative Matrix Factorization: A New Algorithm and Comparisons, % In Proceedings of the 2008 Eighth IEEE International Conference on Data Mining (ICDM'08), 353-362, 2008 % % Written by Jingu Kim (jingu@cc.gatech.edu) % Copyright 2008-2009 by Jingu Kim and Haesun Park, % School of Computational Science and Engineering, % Georgia Institute of Technology % % Check updated code at http://www.cc.gatech.edu/~jingu % Please send bug reports, comments, or questions to Jingu Kim. % This code comes with no guarantee or warranty of any kind. Note that this algorithm assumes that the % input matrix A has full column rank. % % Last modified Feb-20-2009 % % % A : input matrix (m x n) (by default), or A'*A (n x n) if isInputProd==1 % B : input matrix (m x k) (by default), or A'*B (n x k) if isInputProd==1 % isInputProd : (optional, default:0) if turned on, use (A'*A,A'*B) as input instead of (A,B) % init : (optional) initial value for X % % X : the solution (n x k) % Y : A'*A*X - A'*B where X is the solution (n x k) % iter : number of iterations % success : 1 for success, 0 for failure. % Failure could only happen on a numericall very ill-conditioned problem. if nargin<3, isInputProd=0;, end if isInputProd AtA = A;, AtB = B; else AtA = A'*A;, AtB = A'*B; end [n,k]=size(AtB); MAX_ITER = n*5; % set initial feasible solution X = zeros(n,k); if nargin<4 Y = - AtB; PassiveSet = false(n,k); iter = 0; else PassiveSet = (init > 0); [ X,iter ] = solveNormalEqComb(AtA,AtB,PassiveSet); Y = AtA * X - AtB; end % parameters pbar = 3; P = zeros(1,k);, P(:) = pbar; Ninf = zeros(1,k);, Ninf(:) = n+1; iter = 0; NonOptSet = (Y < 0) & ~PassiveSet; InfeaSet = (X < 0) & PassiveSet; NotGood = sum(NonOptSet)+sum(InfeaSet); NotOptCols = NotGood > 0; bigIter = 0;, success=1; while(~isempty(find(NotOptCols))) bigIter = bigIter+1; if ((MAX_ITER >0) && (bigIter > MAX_ITER)) % set max_iter for ill-conditioned (numerically unstable) case success = 0;, break end Cols1 = NotOptCols & (NotGood < Ninf); Cols2 = NotOptCols & (NotGood >= Ninf) & (P >= 1); Cols3Ix = find(NotOptCols & ~Cols1 & ~Cols2); if ~isempty(find(Cols1)) P(Cols1) = pbar;,Ninf(Cols1) = NotGood(Cols1); PassiveSet(NonOptSet & repmat(Cols1,n,1)) = true; PassiveSet(InfeaSet & repmat(Cols1,n,1)) = false; end if ~isempty(find(Cols2)) P(Cols2) = P(Cols2)-1; PassiveSet(NonOptSet & repmat(Cols2,n,1)) = true; PassiveSet(InfeaSet & repmat(Cols2,n,1)) = false; end if ~isempty(Cols3Ix) for i=1:length(Cols3Ix) Ix = Cols3Ix(i); toChange = max(find( NonOptSet(:,Ix)|InfeaSet(:,Ix) )); if PassiveSet(toChange,Ix) PassiveSet(toChange,Ix)=false; else PassiveSet(toChange,Ix)=true; end end end NotOptMask = repmat(NotOptCols,n,1); [ X(:,NotOptCols),subiter ] = solveNormalEqComb(AtA,AtB(:,NotOptCols),PassiveSet(:,NotOptCols)); iter = iter + subiter; X(abs(X)<1e-12) = 0; % for numerical stability Y(:,NotOptCols) = AtA * X(:,NotOptCols) - AtB(:,NotOptCols); Y(abs(Y)<1e-12) = 0; % for numerical stability % check optimality NonOptSet = NotOptMask & (Y < 0) & ~PassiveSet; InfeaSet = NotOptMask & (X < 0) & PassiveSet; NotGood = sum(NonOptSet)+sum(InfeaSet); NotOptCols = NotGood > 0; end endfunction function [ Z,iter ] = solveNormalEqComb( AtA,AtB,PassSet ) % Solve normal equations using combinatorial grouping. % Although this function was originally adopted from the code of % "M. H. Van Benthem and M. R. Keenan, J. Chemometrics 2004; 18: 441-450", % important modifications were made to fix bugs. % % Modified by Jingu Kim (jingu@cc.gatech.edu) % School of Computational Science and Engineering, % Georgia Institute of Technology % % Last updated Aug-12-2009 iter = 0; if (nargin ==2) || isempty(PassSet) || all(PassSet(:)) Z = AtA\AtB; iter = iter + 1; else Z = zeros(size(AtB)); [n,k1] = size(PassSet); ## Fixed on Aug-12-2009 if k1==1 Z(PassSet)=AtA(PassSet,PassSet)\AtB(PassSet); else ## Fixed on Aug-12-2009 % The following bug was identified by investigating a bug report by Hanseung Lee. [sortedPassSet,sortIx] = sortrows(PassSet'); breaks = any(diff(sortedPassSet)'); breakIx = [0 find(breaks) k1]; % codedPassSet = 2.^(n-1:-1:0)*PassSet; % [sortedPassSet,sortIx] = sort(codedPassSet); % breaks = diff(sortedPassSet); % breakIx = [0 find(breaks) k1]; for k=1:length(breakIx)-1 cols = sortIx(breakIx(k)+1:breakIx(k+1)); vars = PassSet(:,sortIx(breakIx(k)+1)); Z(vars,cols) = AtA(vars,vars)\AtB(vars,cols); iter = iter + 1; end end end endfunction %!shared m, n, k, A %! m = 30; %! n = 20; %! k = 10; %! A = rand(m,n); %!test %! [W,H,iter,HIS]=nmf_bpas(A,k); %!test %! [W,H,iter,HIS]=nmf_bpas(A,k,'verbose'); %!test %! [W,H,iter,HIS]=nmf_bpas(A,k,'verbose','nnlssolver','as'); %!test %! [W,H,iter,HIS]=nmf_bpas(A,k,'verbose','type','sparse'); %!test %! [W,H,iter,HIS]=nmf_bpas(A,k,'verbose','type','sparse','nnlssolver','bp','alpha',1.1,'beta',1.3); %!test %! [W,H,iter,HIS]=nmf_bpas(A,k,'verbose','type','plain','winit',rand(m,k)); %!demo %! m = 300; %! n = 200; %! k = 10; %! %! W_org = rand(m,k);, W_org(rand(m,k)>0.5)=0; %! H_org = rand(k,n);, H_org(rand(k,n)>0.5)=0; %! %! % normalize W, since 'nmf' normalizes W before return %! norm2=sqrt(sum(W_org.^2,1)); %! toNormalize = norm2 > eps; %! W_org(:,toNormalize) = W_org(:,toNormalize) ./ norm2(toNormalize); %! %! A = W_org * H_org; %! %! [W,H,iter,HIS]=nmf_bpas (A,k,'type','plain','tol',1e-4); %! %! % -------------------- column reordering before computing difference %! reorder = zeros(k,1); %! selected = zeros(k,1); %! for i=1:k %! for j=1:k %! if ~selected(j), break, end %! end %! minIx = j; %! %! for j=minIx+1:k %! if ~selected(j) %! d1 = norm(W(:,i)-W_org(:,minIx)); %! d2 = norm(W(:,i)-W_org(:,j)); %! if (d2. ## -*- texinfo -*- ## @deftypefn{Function File} {[@var{q}, @var{r}, @var{z}] =} cod (@var{a}) ## @deftypefnx{Function File} {[@var{q}, @var{r}, @var{z}, @var{p}] =} cod (@var{a}) ## @deftypefnx{Function File} {[@dots{}] =} cod (@var{a}, '0') ## Computes the complete orthogonal decomposition (COD) of the matrix @var{a}: ## @example ## @var{a} = @var{q}*@var{r}*@var{z}' ## @end example ## Let @var{a} be an M-by-N matrix, and let @code{K = min(M, N)}. ## Then @var{q} is M-by-M orthogonal, @var{z} is N-by-N orthogonal, ## and @var{r} is M-by-N such that @code{@var{r}(:,1:K)} is upper ## trapezoidal and @code{@var{r}(:,K+1:N)} is zero. ## The additional @var{p} output argument specifies that pivoting should be used in ## the first step (QR decomposition). In this case, ## @example ## @var{a}*@var{p} = @var{q}*@var{r}*@var{z}' ## @end example ## If a second argument of '0' is given, an economy-sized factorization is returned ## so that @var{r} is K-by-K. ## ## @emph{NOTE}: This is currently implemented by double QR factorization plus some ## tricky manipulations, and is not as efficient as using xRZTZF from LAPACK. ## @seealso{qr} ## @end deftypefn ## Author: Jaroslav Hajek function [q, r, z, p] = cod (a, varargin) if (nargin < 1 || nargin > 2 || nargout > 4 || ! (ismatrix (a) && isnumeric (a))) print_usage (); endif [m, n] = size (a); k = min (m, n); economy = nargin == 2; pivoted = nargout == 4; ## Compute the initial QR decomposition if (pivoted) [q, r, p] = qr (a, varargin{:}); else [q, r] = qr (a, varargin{:}); endif if (m >= n) ## In this case, Z is identity, and we're finished. z = eye (n, class (a)); else ## Permutation inverts row order. pr = eye (m) (m:-1:1, :); ## Permutation inverts first m columns order. pc = eye (n) ([m:-1:1, m+1:n], :); ## Make n-by-m matrix, invert first m columns r = (pr * r * pc')'; ## QR factorize again. [z, r] = qr (r, varargin{:}); ## Recover final R and Z if (economy) r = pr * r' * pr'; z = pc * z * pr'; else r = pr * r' * pc'; z = pc * z * pc'; endif endif endfunction %!test %! a = rand (5, 10); %! [q, r, z] = cod (a); %! assert (norm (q*r*z' - a) / norm (a) < 1e-10); %!test %! a = rand (5, 10) + i * rand (5, 10); %! [q, r, z] = cod (a); %! assert (norm (q*r*z' - a) / norm (a) < 1e-10); %!test %! a = rand (5, 10); %! [q, r, z, p] = cod (a); %! assert (norm (q*r*z' - a*p) / norm (a) < 1e-10); linear-algebra-2.2.4/inst/PaxHeaders/circulant_inv.m0000644000000000000000000000006215146653315017450 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/inst/circulant_inv.m0000644000175000017500000000371315146653315017770 0ustar00philipphilip## Copyright (C) 2012 Nir Krakauer ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn{Function File} {@var{c} =} circulant_inv (@var{v}) ## ## Fast, compact calculation of inverse of a circulant matrix@* ## Given an @var{n}*1 vector @var{v}, return the inverse @var{c} of the @var{n}*@var{n} circulant matrix @var{C} that has @var{v} as its first column ## The returned @var{c} is the first column of the inverse, which is also circulant -- to get the full matrix, use `circulant_make_matrix(c)' ## ## Theoretically same as @code{inv(make_circulant_matrix(v))(:, 1)}, but requires many fewer computations and does not form matrices explicitly ## ## Roundoff may induce a small imaginary component in @var{c} even if @var{v} is real -- use @code{real(c)} to remedy this ## ## Reference: Robert M. Gray, Toeplitz and Circulant Matrices: A Review, Now Publishers, http://ee.stanford.edu/~gray/toeplitz.pdf, Chapter 3 ## ## @seealso{gallery, circulant_matrix_vector_product, circulant_eig} ## @end deftypefn function c = circulant_inv(v) ## Find the eigenvalues and eigenvectors [vs, lambda] = circulant_eig(v); ## Find the first column of the inverse c = vs * diag(1 ./ diag(lambda)) * conj(vs(:, 1)); endfunction %!shared v %! v = [1 2 3]'; %!assert (gallery ("circul", circulant_inv (v)), inv (gallery ("circul", v)), 10*eps); linear-algebra-2.2.4/PaxHeaders/Makefile0000644000000000000000000000006215146653315015115 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/Makefile0000644000175000017500000002105315146653315015432 0ustar00philipphilip## Copyright 2015-2026 CarnĂ« Draug ## Copyright 2015-2026 Oliver Heimlich ## Copyright 2017-2026 Julien Bect ## Copyright 2017-2026 Olaf Till ## ## Copying and distribution of this file, with or without modification, ## are permitted in any medium without royalty provided the copyright ## notice and this notice are preserved. This file is offered as-is, ## without any warranty. ## Some basic tools (can be overriden using environment variables) SED ?= sed TAR ?= tar GREP ?= grep CUT ?= cut TR ?= tr ## Note the use of ':=' (immediate set) and not just '=' (lazy set). ## http://stackoverflow.com/a/448939/1609556 package := $(shell $(GREP) "^Name: " DESCRIPTION | $(CUT) -f2 -d" " | \ $(TR) '[:upper:]' '[:lower:]') version := $(shell $(GREP) "^Version: " DESCRIPTION | $(CUT) -f2 -d" ") ## These are the paths that will be created for the releases. target_dir := target release_dir := $(target_dir)/$(package)-$(version) release_tarball := $(target_dir)/$(package)-$(version).tar.gz html_dir := $(target_dir)/$(package)-html html_tarball := $(target_dir)/$(package)-html.tar.gz ## Using $(realpath ...) avoids problems with symlinks due to bug ## #50994 in Octaves scripts/pkg/private/install.m. But at least the ## release directory above is needed in the relative form, for 'git ## archive --format=tar --prefix=$(release_dir). real_target_dir := $(realpath .)/$(target_dir) installation_dir := $(real_target_dir)/.installation package_list := $(installation_dir)/.octave_packages install_stamp := $(installation_dir)/.install_stamp ## These can be set by environment variables which allow to easily ## test with different Octave versions. ifndef OCTAVE OCTAVE := octave endif OCTAVE := $(OCTAVE) --no-gui --silent --no-history --norc MKOCTFILE ?= mkoctfile ## Command used to set permissions before creating tarballs FIX_PERMISSIONS ?= chmod -R a+rX,u+w,go-w,ug-s ## Detect which VCS is used vcs := $(if $(wildcard .hg),hg,$(if $(wildcard .git),git,unknown)) ifeq ($(vcs),hg) release_dir_dep := .hg/dirstate endif ifeq ($(vcs),git) release_dir_dep := .git/index endif ## .PHONY indicates targets that are not filenames ## (https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html) .PHONY: help ## make will display the command before runnning them. Use @command ## to not display it (makes specially sense for echo). help: @echo "Targets:" @echo " dist - Create $(release_tarball) for release." @echo " html - Create $(html_tarball) for release." @echo " release - Create both of the above and show md5sums." @echo " install - Install the package in $(installation_dir), where it is not visible in a normal Octave session." @echo " check - Execute package tests." @echo " doctest - Test the help texts with the doctest package." @echo " run - Run Octave with the package installed in $(installation_dir) in the path." @echo " clean - Remove everything made with this Makefile." ## ## Recipes for release tarballs (package + html) ## .PHONY: release dist html clean-tarballs clean-unpacked-release ## To make a release, build the distribution and html tarballs. release: dist html md5sum $(release_tarball) $(html_tarball) @echo "Upload @ https://sourceforge.net/p/octave/package-releases/new/" @echo " and note the changeset the release corresponds to" ## dist and html targets are only PHONY/alias targets to the release ## and html tarballs. dist: $(release_tarball) html: $(html_tarball) ## An implicit rule with a recipe to build the tarballs correctly. %.tar.gz: % $(TAR) -c -f - --posix -C "$(target_dir)/" "$(notdir $<)" | gzip -9n > "$@" clean-tarballs: @echo "## Cleaning release tarballs (package + html)..." -$(RM) $(release_tarball) $(html_tarball) @echo ## Create the unpacked package. ## ## Notes: ## * having ".hg/dirstate" (or ".git/index") as a prerequesite means it is ## only rebuilt if we are at a different commit. ## * the variable RM usually defaults to "rm -f" ## * having this recipe separate from the one that makes the tarball ## makes it easy to have packages in alternative formats (such as zip) ## * note that if a commands needs to be run in a specific directory, ## the command to "cd" needs to be on the same line. Each line restores ## the original working directory. $(release_dir): $(release_dir_dep) -$(RM) -r "$@" ifeq (${vcs},hg) hg archive --exclude ".hg*" --type files "$@" endif ifeq (${vcs},git) git archive --format=tar --prefix="$@/" HEAD | $(TAR) -x $(RM) "$@/.gitignore" endif ## Don't fall back to run the supposed necessary contents of ## 'bootstrap' here. Users are better off if they provide ## 'bootstrap'. Administrators, checking build reproducibility, can ## put in the missing 'bootstrap' file if they feel they know its ## necessary contents. ifneq (,$(wildcard src/bootstrap)) cd "$@/src" && ./bootstrap && $(RM) -r "autom4te.cache" endif ## Uncomment this if your src/Makefile.in has these targets for ## pre-building something for the release (e.g. documentation). # cd "$@/src" && ./configure && $(MAKE) prebuild && \ # $(MAKE) distclean && $(RM) Makefile ## ${FIX_PERMISSIONS} "$@" run_in_place = $(OCTAVE) --eval ' pkg ("local_list", "$(package_list)"); ' \ --eval ' pkg ("load", "$(package)"); ' html_options = --eval 'options = get_html_options ("octave-forge");' disableVM = --eval 'try; __vm_enable__ (0); end_try_catch; ' ## Uncomment this for package documentation. # html_options = --eval 'options = get_html_options ("octave-forge");' \ # --eval 'options.package_doc = "$(package).texi";' $(html_dir): $(install_stamp) $(RM) -r "$@"; $(run_in_place) \ --eval ' pkg load generate_html; ' \ $(disableVM) \ $(html_options) \ --eval ' generate_package_html ("$(package)", "$@", options); '; $(FIX_PERMISSIONS) "$@"; clean-unpacked-release: @echo "## Cleaning unpacked release tarballs (package + html)..." -$(RM) -r $(release_dir) $(html_dir) @echo ## ## Recipes for installing the package. ## .PHONY: install clean-install octave_install_commands = \ ' llist_path = pkg ("local_list"); \ mkdir ("$(installation_dir)"); \ load (llist_path); \ local_packages(cellfun (@ (x) strcmp ("$(package)", x.name), local_packages)) = []; \ save ("$(package_list)", "local_packages"); \ pkg ("local_list", "$(package_list)"); \ pkg ("prefix", "$(installation_dir)", "$(installation_dir)"); \ pkg ("install", "-local", "-verbose", "$(release_tarball)"); ' ## Install unconditionally. Maybe useful for testing installation with ## different versions of Octave. install: $(release_tarball) @echo "Installing package under $(installation_dir) ..." $(OCTAVE) --eval $(octave_install_commands) touch $(install_stamp) ## Install only if installation (under target/...) is not current. $(install_stamp): $(release_tarball) @echo "Installing package under $(installation_dir) ..." $(OCTAVE) --eval $(octave_install_commands) touch $(install_stamp) clean-install: @echo "## Cleaning installation under $(installation_dir) ..." -$(RM) -r $(installation_dir) @echo ## ## Recipes for testing purposes ## .PHONY: run doctest check ## Start an Octave session with the package directories on the path for ## interactice test of development sources. run: $(install_stamp) $(run_in_place) --persist ## Test example blocks in the documentation. Needs doctest package ## https://octave.sourceforge.io/doctest/index.html doctest: $(install_stamp) $(run_in_place) --eval 'pkg load doctest;' \ --eval "targets = '$(shell (ls inst; ls src | $(GREP) .oct) | $(CUT) -f2 -d@ | $(CUT) -f1 -d.)';" \ --eval "targets = strsplit (targets, ' '); doctest (targets);" ## Test package. octave_test_commands = \ ' dirs = {"inst", "src"}; \ dirs(cellfun (@ (x) ! isdir (x), dirs)) = []; \ if (isempty (dirs)) error ("no \"inst\" or \"src\" directory"); exit (1); \ else __run_test_suite__ (dirs, {}); endif ' ## the following works, too, but provides no overall summary output as ## __run_test_suite__ does: ## ## else cellfun (@runtests, horzcat (cellfun (@ (dir) ostrsplit (([~, dirs] = system (sprintf ("find %s -type d", dir))), "\n\r", true), dirs, "UniformOutput", false){:})); endif ' check: $(install_stamp) $(run_in_place) --eval $(octave_test_commands) ## ## CLEAN ## .PHONY: clean clean: clean-tarballs clean-unpacked-release clean-install @echo "## Removing target directory (if empty)..." -rmdir $(target_dir) @echo @echo "## Cleaning done" @echo linear-algebra-2.2.4/PaxHeaders/DESCRIPTION0000644000000000000000000000006215146653315015163 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/DESCRIPTION0000644000175000017500000000056215146653315015502 0ustar00philipphilipName: linear-algebra Version: 2.2.4 Date: 2026-02-22 Author: various authors Maintainer: Octave-Forge community Title: Linear algebra. Description: Additional linear algebra code, including matrix functions. Categories: Linear algebra Depends: octave (>= 4.0.0) Autoload: no License: GPLv3+, LGPLv3+, FreeBSD Url: http://octave.sf.net linear-algebra-2.2.4/PaxHeaders/COPYING0000644000000000000000000000006215146653315014510 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/COPYING0000644000175000017500000000004215146653315015020 0ustar00philipphilipSee individual files for licenses linear-algebra-2.2.4/PaxHeaders/NEWS0000644000000000000000000000006215146653315014154 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/NEWS0000644000175000017500000000676415146653315014505 0ustar00philipphilipSummary of important user-visible changes for linear-algebra 2.2.4: ------------------------------------------------------------------- ** The following function is removed from the package if installed in Octave >= 11.1.0: funm.m (a much improved funm.m has been added to Octave-11.1.0) ** Package documentation is now included in the GUI doc pane (if the package has been loaded). Summary of important user-visible changes for linear-algebra 2.2.3: ------------------------------------------------------------------- ** The following functions have been removed from the package. They have been in Octave core since version 4.4 or earlier: condeig gsvd pgmres (superseded by gmres in core Octave) Summary of important user-visible changes for linear-algebra 2.2.2: ------------------------------------------------------------------- ** Several functions have been adapted to the new core-Octave "ismatrix" behavior (the latter only checks for 2D size, not class). To this end all input matrices are checked against the "isnumeric" function. The linear-algebra package is expected to still work for older Octave versions than 4.0.0 as this "isnumeric" check is only additional. ** nmf_* functions use inputParser from Octave 4.0.0. They won't work with older versions. ** The interface of nmf_bpas has been simplified. The option 'verbose' is now a switch and it doesn't require a value. The history of the calculations is stored and returned only if the 4th output argument is requested. ** Package is no longer dependent on general (>= 1.3.0) Summary of important user-visible changes for linear-algebra 2.2.1: ------------------------------------------------------------------- ** The following functions is new in 2.2.1: vec_projection ** fixed bugs: nmf_pg doesn't use text_waitbar by default. The miscellaneous package is not required. nmf_bpas now respects the verbose option @blksparse/ctranspose returns a Block Sparse Matrix @kronprod/iscomplex.m, @kronprod/uminus.m:fixtypos src/CmplxGSVD.cc, src/dbleGSVD.cc: update Array constructor usage funm.m: fix texinfo, fix typo preventing thfm invocation where applicable, return real matrix when all |imaginary entries| < eps @kronprod and @blksparse subfunctions have been documented ** Makefile fixed to work with non-standard linker options e.g on Apple. ** The function circulant_make_matrix has been deprecated and will be removed from future versions of the linear-algebra package. Summary of important user-visible changes for linear-algebra 2.2.0: ------------------------------------------------------------------- ** The following functions are new in 2.2.0: circulant_eig circulant_inv circulant_make_matrix circulant_matrix_vector_product nmf_pg nmf_bpas ** Package is now dependent on general (>= 1.3.0) ** Package is no longer automatically loaded. Summary of important user-visible changes for linear-algebra 2.1.0: ------------------------------------------------------------------- ** The following functions are new in 2.1.0: lobpcg ndcovlt ** The following functions were removed since equivalents are now part of GNU octave core: bicg mgorth ** The following functions were deprecated since equivalents are now part of GNU octave core: pgmres ** The function `funm' now also accepts function handles. ** Help text of most functions has been improved. linear-algebra-2.2.4/PaxHeaders/doc0000644000000000000000000000013215146653556014152 xustar0030 mtime=1771788142.194370838 30 atime=1771788142.228370636 30 ctime=1771788142.228370636 linear-algebra-2.2.4/doc/0000755000175000017500000000000015146653556014545 5ustar00philipphiliplinear-algebra-2.2.4/doc/PaxHeaders/linear-algebra.css0000644000000000000000000000006215146653315017601 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/doc/linear-algebra.css0000644000175000017500000000133715146653315020121 0ustar00philipphilippre.example, .header, .float-caption, hr { /* base00 ~ body text in light solarized theme */ color: #657b83; border-color: #657b83; } pre.example { /* base3 ~ background color in light solarized theme */ background-color: #fdf6e3; padding: 0.5em; } table.cartouche { border: 1px solid #948473; background-color: #FFE3C6; width: 100%; } table.cartouche td, table.cartouche th { border: 1px solid #948473; padding: 4px 4px; } /* newer texinfo generation styles */ div.example { /* base00 ~ body text in light solarized theme */ color: #657b83; border-color: #657b83; } pre.example-preformatted { /* base3 ~ background color in light solarized theme */ background-color: #fdf6e3; padding: 0.5em; } linear-algebra-2.2.4/doc/PaxHeaders/Makefile0000644000000000000000000000006215146653315015662 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/doc/Makefile0000644000175000017500000000743015146653315016202 0ustar00philipphilip## Makefile to simplify Octave Forge package maintenance tasks ## ## Copyright 2015-2016 CarnĂ« Draug ## Copyright 2015-2016 Oliver Heimlich ## Copyright 2015-2019 Mike Miller ## Copyright 2024-2026 John Donoghue ## ## Copying and distribution of this file, with or without modification, ## are permitted in any medium without royalty provided the copyright ## notice and this notice are preserved. This file is offered as-is, ## without any warranty. MKOCTFILE ?= mkoctfile OCTAVE ?= octave SED := sed SHA256SUM := sha256sum TAR := tar MAKEINFO ?= makeinfo MAKEINFO_HTML_OPTIONS := --no-headers --set-customization-variable 'COPIABLE_LINKS 0' --set-customization-variable 'COPIABLE_ANCHORS 0' --no-split # work out a possible help generator ifeq ($(strip $(QHELPGENERATOR)),) ifneq ($(shell qhelpgenerator-qt5 -v 2>/dev/null),) QHELPGENERATOR = qhelpgenerator-qt5 else ifneq ($(shell qcollectiongenerator-qt5 -v 2>/dev/null),) QHELPGENERATOR = qcollectiongenerator-qt5 #else ifneq ($(shell qhelpgenerator -qt5 -v 2>/dev/null),) # v4 doesnt work # QHELPGENERATOR = qhelpgenerator -qt5 else ifneq ($(shell qcollectiongenerator -qt5 -v 2>/dev/null),) QHELPGENERATOR = qcollectiongenerator -qt5 else QHELPGENERATOR = true endif endif PACKAGE := $(shell $(SED) -n -e 's/^Name: *\(\w\+\)/\1/p' ../DESCRIPTION) VERSION := $(shell $(SED) -n -e 's/^Version: *\(\w\+\)/\1/p' ../DESCRIPTION) DATE := $(shell $(SED) -n -e 's/^Date: *\(\w\+\)/\1/p' ../DESCRIPTION) DEPENDS := $(shell $(SED) -n -e 's/^Depends[^,]*, *\(.*\)/\1/p' ../DESCRIPTION | $(SED) 's/ *([^()]*)//g; s/ *, */ /g') BASEDIR ?= $(realpath $(CURDIR)) HG := hg HG_CMD = $(HG) --config alias.$(1)=$(1) --config defaults.$(1)= $(1) HG_ID := $(shell $(call HG_CMD,identify) --id | sed -e 's/+//' ) HG_TIMESTAMP := $(firstword $(shell $(call HG_CMD,log) --rev $(HG_ID) --template '{date|hgdate}')) TAR_REPRODUCIBLE_OPTIONS := --sort=name --mtime="@$(HG_TIMESTAMP)" --owner=0 --group=0 --numeric-owner TAR_OPTIONS := --format=ustar $(TAR_REPRODUCIBLE_OPTIONS) RELEASE_DIR := $(PACKAGE)-$(VERSION) RELEASE_TARBALL := $(PACKAGE)-$(VERSION).tar.gz HTML_DIR := $(PACKAGE)-html HTML_TARBALL := $(PACKAGE)-html.tar.gz .PHONY: doc clean maintainer-clean .PHONY: build-docs cleandocs help: @echo "Targets:" @echo " doc - Build Texinfo package manual" @echo @echo " clean - Remove releases, html documentation, and oct files" @echo " maintainer-clean - Additionally remove all generated files" doc: build-docs version.texi: $(BASEDIR)/../.hg/dirstate @echo Generating $@ @echo "@c autogenerated from Makefile" > $@ @echo "@set VERSION $(VERSION)" >> $@ @echo "@set PACKAGE $(PACKAGE)" >> $@ @echo "@set DATE $(DATE)" >> $@ functions.texi: $(BASEDIR)/../.hg/dirstate ./mkfuncdocs.py --src-dir=../inst/ --src-dir=../src/ ../INDEX | $(SED) 's/@seealso/@xseealso/g' > functions.texi $(PACKAGE).qhc: $(PACKAGE).texi functions.texi version.texi # extract html SOURCE_DATE_EPOCH=$(HG_TIMESTAMP) $(MAKEINFO) --html --css-ref=$(PACKAGE).css $(MAKEINFO_HTML_OPTIONS) $(PACKAGE).texi ifeq ($(QHELPGENERATOR),true) $(warning No QHELPGENERATOR ... skipping QT doc build) else # try also create qch file if can ./mkqhcp.py $(PACKAGE) && $(QHELPGENERATOR) $(PACKAGE).qhcp -o $(PACKAGE).qhc $(RM) -f $(PACKAGE).qhcp $(PACKAGE).qhp $(PACKAGE).html endif $(PACKAGE).info: $(PACKAGE).texi functions.texi version.texi $(MAKEINFO) $(PACKAGE).texi build-docs: $(PACKAGE).qhc $(PACKAGE).info clean-docs: $(RM) -f $(PACKAGE).html $(RM) -f $(PACKAGE).qhc $(RM) -f $(PACKAGE).qch $(RM) -f $(PACKAGE).info $(RM) -f functions.texi $(RM) -f version.texi clean: clean-docs -rm -rf $(RELEASE_DIR) $(RELEASE_TARBALL) $(HTML_TARBALL) $(HTML_DIR) cd src && $(MAKE) $@ maintainer-clean: clean linear-algebra-2.2.4/doc/PaxHeaders/gpl.texi0000644000000000000000000000006215146653315015677 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/doc/gpl.texi0000644000175000017500000010433015146653315016214 0ustar00philipphilip@node Copying @appendix GNU General Public License @cindex warranty @cindex copyright @center Version 3, 29 June 2007 @display Copyright @copyright{} 2007 Free Software Foundation, Inc. @url{http://fsf.org/} Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @end display @heading Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program---to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. @heading TERMS AND CONDITIONS @enumerate 0 @item Definitions. ``This License'' refers to version 3 of the GNU General Public License. ``Copyright'' also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. ``The Program'' refers to any copyrightable work licensed under this License. Each licensee is addressed as ``you''. ``Licensees'' and ``recipients'' may be individuals or organizations. To ``modify'' a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a ``modified version'' of the earlier work or a work ``based on'' the earlier work. A ``covered work'' means either the unmodified Program or a work based on the Program. To ``propagate'' a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To ``convey'' a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays ``Appropriate Legal Notices'' to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. @item Source Code. The ``source code'' for a work means the preferred form of the work for making modifications to it. ``Object code'' means any non-source form of a work. A ``Standard Interface'' means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The ``System Libraries'' of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A ``Major Component'', in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The ``Corresponding Source'' for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. @item Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. @item Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. @item Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. @item Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: @enumerate a @item The work must carry prominent notices stating that you modified it, and giving a relevant date. @item The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to ``keep intact all notices''. @item You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. @item If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. @end enumerate A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an ``aggregate'' if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. @item Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: @enumerate a @item Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. @item Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. @item Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. @item Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. @item Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. @end enumerate A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A ``User Product'' is either (1) a ``consumer product'', which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, ``normally used'' refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. ``Installation Information'' for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. @item Additional Terms. ``Additional permissions'' are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: @enumerate a @item Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or @item Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or @item Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or @item Limiting the use for publicity purposes of names of licensors or authors of the material; or @item Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or @item Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. @end enumerate All other non-permissive additional terms are considered ``further restrictions'' within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. @item Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. @item Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. @item Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An ``entity transaction'' is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. @item Patents. A ``contributor'' is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's ``contributor version''. A contributor's ``essential patent claims'' are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, ``control'' includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a ``patent license'' is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To ``grant'' such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. ``Knowingly relying'' means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is ``discriminatory'' if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. @item No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. @item Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. @item Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License ``or any later version'' applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. @item Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. @item Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. @item Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. @end enumerate @heading END OF TERMS AND CONDITIONS @heading How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the ``copyright'' line and a pointer to where the full notice is found. @smallexample @var{one line to give the program's name and a brief idea of what it does.} Copyright (C) @var{year} @var{name of author} This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see @url{http://www.gnu.org/licenses/}. @end smallexample Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: @smallexample @var{program} Copyright (C) @var{year} @var{name of author} This program comes with ABSOLUTELY NO WARRANTY; for details type @samp{show w}. This is free software, and you are welcome to redistribute it under certain conditions; type @samp{show c} for details. @end smallexample The hypothetical commands @samp{show w} and @samp{show c} should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an ``about box''. You should also get your employer (if you work as a programmer) or school, if any, to sign a ``copyright disclaimer'' for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see @url{http://www.gnu.org/licenses/}. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read @url{http://www.gnu.org/philosophy/why-not-lgpl.html}. linear-algebra-2.2.4/doc/PaxHeaders/version.texi0000644000000000000000000000006215146653315016602 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/doc/version.texi0000644000175000017500000000014315146653315017114 0ustar00philipphilip@c autogenerated from Makefile @set VERSION 2.2.4 @set PACKAGE linear-algebra @set DATE 2026-02-22 linear-algebra-2.2.4/doc/PaxHeaders/linear-algebra.qhc0000644000000000000000000000006215146653315017564 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/doc/linear-algebra.qhc0000644000175000017500000031000015146653315020072 0ustar00philipphilipSQLite format 3@ ##.~Z ²¨†’$ º  w † ä h ó z ó H¾"¾fó| ¨b''tableVersionFilterVersionFilterCREATE TABLE VersionFilter (Version TEXT, FilterId INTEGER)n++tableComponentFilterComponentFilterCREATE TABLE ComponentFilter (ComponentName TEXT, FilterId INTEGER)u--tableComponentMappingComponentMappingCREATE TABLE ComponentMapping (ComponentId INTEGER, NamespaceId INTEGER)q))tableComponentTableComponentTableCREATE TABLE ComponentTable (ComponentId INTEGER PRIMARY KEY, Name TEXT)VtableFilterFilterCREATE TABLE Filter (FilterId INTEGER PRIMARY KEY, Name TEXT)b%%tableVersionTableVersionTableCREATE TABLE VersionTable (NamespaceId INTEGER, Version TEXT)))mtableTimeStampTableTimeStampTableCREATE TABLE TimeStampTable (NamespaceId INTEGER, FolderId INTEGER, FilePath TEXT, Size INTEGER, TimeStamp TEXT)551tableOptimizedFilterTableOptimizedFilterTableCREATE TABLE OptimizedFilterTable (NamespaceId INTEGER, FilterAttributeId INTEGER)(77otableFileAttributeSetTableFileAttributeSetTableCREATE TABLE FileAttributeSetTable (NamespaceId INTEGER, FilterAttributeSetId INTEGER, FilterAttributeId INTEGER) 33/tableContentsFilterTableContentsFilterTableCREATE TABLE ContentsFilterTable (FilterAttributeId INTEGER, ContentsId INTEGER )w --!tableIndexFilterTableIndexFilterTable CREATE TABLE IndexFilterTable (FilterAttributeId INTEGER, IndexId INTEGER)s ++tableFileFilterTableFileFilterTable CREATE TABLE FileFilterTable (FilterAttributeId INTEGER, FileId INTEGER)z ''3tableContentsTableContentsTable CREATE TABLE ContentsTable (Id INTEGER PRIMARY KEY, NamespaceId INTEGER, Data BLOB) !!‚ tableIndexTableIndexTable CREATE TABLE IndexTable (Id INTEGER PRIMARY KEY, Name TEXT, Identifier TEXT, NamespaceId INTEGER, FileId INTEGER, Anchor TEXT)''MtableFileNameTableFileNameTable CREATE TABLE FileNameTable (FolderId INTEGER, Name TEXT, FileId INTEGER PRIMARY KEY, Title TEXT)e'' tableSettingsTableSettingsTableCREATE TABLE SettingsTable (Key TEXT PRIMARY KEY, Value BLOB )9M'indexsqlite_autoindex_SettingsTable_1SettingsTableh##tableFilterTableFilterTableCREATE TABLE FilterTable (NameId INTEGER, FilterAttributeId INTEGER )l++tableFilterNameTableFilterNameTableCREATE TABLE FilterNameTable (Id INTEGER PRIMARY KEY, Name TEXT ){55tableFilterAttributeTableFilterAttributeTableCREATE TABLE FilterAttributeTable (Id INTEGER PRIMARY KEY, Name TEXT )u##1tableFolderTableFolderTableCREATE TABLE FolderTable (Id INTEGER PRIMARY KEY, NamespaceId INTEGER, Name TEXT )x))+tableNamespaceTableNamespaceTableCREATE TABLE NamespaceTable (Id INTEGER PRIMARY KEY, Name TEXT, FilePath TEXT ) ÉÉ5K1octave.community.linear-algebralinear-algebra.qch ÷÷ doc    #Ô¶{fS>#9FullTextSearchFallback%CreationTimei›U—) HideAddressBar- EnableAddressBarA EnableDocumentationManager; HideFilterFunctionality? EnableFilterFunctionality*-;LastRegisterTime2026-02-22T20:14:31.632 ?Z~“Î?k²́9FullTextSearchFallback%CreationTime)HideAddressBar-EnableAddressBarAEnableDocumentationManager;HideFilterFunctionality?EnableFilterFunctionality- LastRegisterTime }¨}) 11linear-algebra.csslinear-algebra.cssV 3linear-algebra.htmlOctave linear-algebra - linear-algebra package for GNU octave AÊ×¾¯‰rWF-ÿæ®r4 ü Ê Z ́ ² x B  ̃ ¨ p 4 ₫ Ê ” X * ú Ä ” f ,ôÀˆPæ®zFä´~ѪxF ئXÊQAK ccirculant_matrix_vector_productcirculant_005fmatrix_005fvector_005fproduct9@7 Gcirculant_make_matrixcirculant_005fmake_005fmatrix%?' /circulant_invcirculant_005finv%>' /circulant_eigcirculant_005feig0=+ A@kronprod/uplusg_t_0040kronprod_002fuplus2<- C@kronprod/uminusg_t_0040kronprod_002fuminus8;3 I@kronprod/transposeg_t_0040kronprod_002ftranspose0:+ A@kronprod/traceg_t_0040kronprod_002ftrace09+ A@kronprod/timesg_t_0040kronprod_002ftimes28- C@kronprod/sparseg_t_0040kronprod_002fsparse>75 S@kronprod/size_equalg_t_0040kronprod_002fsize_005fequal.6) ?@kronprod/sizeg_t_0040kronprod_002fsize.5) ?@kronprod/rowsg_t_0040kronprod_002frows44/ E@kronprod/rdivideg_t_0040kronprod_002frdivide.3) ?@kronprod/rankg_t_0040kronprod_002frank.2) ?@kronprod/plusg_t_0040kronprod_002fplus01+ A@kronprod/numelg_t_0040kronprod_002fnumel20- C@kronprod/mtimesg_t_0040kronprod_002fmtimes2/- C@kronprod/mpowerg_t_0040kronprod_002fmpower6.1 G@kronprod/mldivideg_t_0040kronprod_002fmldivide0-+ A@kronprod/minusg_t_0040kronprod_002fminus6,1 G@kronprod/kronprodg_t_0040kronprod_002fkronprod6+1 G@kronprod/issquareg_t_0040kronprod_002fissquare6*1 G@kronprod/issparseg_t_0040kronprod_002fissparse2)- C@kronprod/isrealg_t_0040kronprod_002fisreal6(1 G@kronprod/ismatrixg_t_0040kronprod_002fismatrix8'3 I@kronprod/iscomplexg_t_0040kronprod_002fiscomplex,&' =@kronprod/invg_t_0040kronprod_002finv.%) ?@kronprod/fullg_t_0040kronprod_002ffull4$/ E@kronprod/displayg_t_0040kronprod_002fdisplay.#) ?@kronprod/dispg_t_0040kronprod_002fdisp,"' =@kronprod/detg_t_0040kronprod_002fdet:!5 K@kronprod/ctransposeg_t_0040kronprod_002fctranspose4 / E@kronprod/columnsg_t_0040kronprod_002fcolumns2- C@blksparse/uplusg_t_0040blksparse_002fuplus4/ E@blksparse/uminusg_t_0040blksparse_002fuminus:5 K@blksparse/transposeg_t_0040blksparse_002ftranspose61 G@blksparse/subsrefg_t_0040blksparse_002fsubsref4/ E@blksparse/sparseg_t_0040blksparse_002fsparse0+ A@blksparse/sizeg_t_0040blksparse_002fsize0+ A@blksparse/plusg_t_0040blksparse_002fplus4/ E@blksparse/mtimesg_t_0040blksparse_002fmtimes83 I@blksparse/mrdivideg_t_0040blksparse_002fmrdivide83 I@blksparse/mldivideg_t_0040blksparse_002fmldivide2- C@blksparse/minusg_t_0040blksparse_002fminus83 I@blksparse/issparseg_t_0040blksparse_002fissparse4/ E@blksparse/isrealg_t_0040blksparse_002fisreal83 I@blksparse/ismatrixg_t_0040blksparse_002fismatrix0+ A@blksparse/fullg_t_0040blksparse_002ffull61 G@blksparse/displayg_t_0040blksparse_002fdisplay<7 M@blksparse/ctransposeg_t_0040blksparse_002fctranspose:5 K@blksparse/blksparseg_t_0040blksparse_002fblksparse6 1 G@blksparse/blksizeg_t_0040blksparse_002fblksize  !nmf_pgnmf_005fpg  %nmf_bpasnmf_005fbpas  thfmthfm  smwsolvesmwsolve rotvrotv rotparamsrotparams ndcovltndcovlt lobpcglobpcg funmfunm  codcod cartprodcartprod') 1vec_projectionvec_005fprojection !!ƠP « &linear-algebra.htmlˆOctave linear-algebra - linear-algebra package for GNU octave Manual8linear-algebra.html#Overview1 OverviewTlinear-algebra.html#Installing-and-loading02 Installing and loadingFlinear-algebra.html#Windows-install&2.1 Windows install<linear-algebra.html#Installing2.2 Installing6linear-algebra.html#Loading2.3 LoadingLlinear-algebra.html#Function-Reference(3 Function ReferenceHlinear-algebra.html#Vector-functions(3.1 Vector functionsLlinear-algebra.html#vec_005fprojection(3.1.1 vec_projectionHlinear-algebra.html#Matrix-functions(3.2 Matrix functions8linear-algebra.html#cartprod3.2.1 cartprod.linear-algebra.html#cod3.2.2 cod0linear-algebra.html#funm3.2.3 funm4linear-algebra.html#lobpcg3.2.4 lobpcg6linear-algebra.html#ndcovlt3.2.5 ndcovlt:linear-algebra.html#rotparams3.2.6 rotparams0linear-algebra.html#rotv3.2.7 rotv8linear-algebra.html#smwsolve3.2.8 smwsolve0linear-algebra.html#thfm3.2.9 thfmPlinear-algebra.html#Matrix-factorization03.3 Matrix factorization@linear-algebra.html#nmf_005fbpas3.3.1 nmf_bpas<linear-algebra.html#nmf_005fpg3.3.2 nmf_pgRlinear-algebra.html#Block-sparse-matrices23.4 Block sparse matricesblinear-algebra.html#g_t_0040blksparse_002fblksize03.4.1 @blksparse/blksizeflinear-algebra.html#g_t_0040blksparse_002fblksparse      ËË3 1=linear-algebra.qch@2026-02-22T19:14:31.627Z ûû  øødoc ûû  43.4.2 @blksparse/blksparsehlinear-algebra.html#g_t_0040blksparse_002fctranspose63.4.3 @blksparse/ctransposeblinear-algebra.html#g_t_0040blksparse_002fdisplay03.4.4 @blksparse/display\linear-algebra.html#g_t_0040blksparse_002ffull*3.4.5 @blksparse/fulldlinear-algebra.html#g_t_0040blksparse_002fismatrix23.4.6 @blksparse/ismatrix`linear-algebra.html#g_t_0040blksparse_002fisreal.3.4.7 @blksparse/isrealdlinear-algebra.html#g_t_0040blksparse_002fissparse23.4.8 @blksparse/issparse^linear-algebra.html#g_t_0040blksparse_002fminus,3.4.9 @blksparse/minusdlinear-algebra.html#g_t_0040blksparse_002fmldivide43.4.10 @blksparse/mldividedlinear-algebra.html#g_t_0040blksparse_002fmrdivide43.4.11 @blksparse/mrdivide`linear-algebra.html#g_t_0040blksparse_002fmtimes03.4.12 @blksparse/mtimes\linear-algebra.html#g_t_0040blksparse_002fplus,3.4.13 @blksparse/plus\linear-algebra.html#g_t_0040blksparse_002fsize,3.4.14 @blksparse/size`linear-algebra.html#g_t_0040blksparse_002fsparse03.4.15 @blksparse/sparseblinear-algebra.html#g_t_0040blksparse_002fsubsref23.4.16 @blksparse/subsrefflinear-algebra.html#g_t_0040blksparse_002ftranspose63.4.17 @blksparse/transpose`linear-algebra.html#g_t_0040blksparse_002fuminus03.4.18 @blksparse/uminus^linear-algebra.html#g_t_0040blksparse_002fuplus.3.4.19 @blksparse/uplusLlinear-algebra.html#Kronecker-Products,3.5 Kronecker Products`linear-algebra.html#g_t_0040kronprod_002fcolumns.3.5.1 @kronprod/columnsflinear-algebra.html#g_t_0040kronprod_002fctranspose43.5.2 @kronprod/ctransposeXlinear-algebra.html#g_t_0040kronprod_002fdet&3.5.3 @kronprod/detZlinear-algebra.html#g_t_0040kronprod_002fdisp(3.5.4 @kronprod/disp`linear-algebra.html#g_t_0040kronprod_002fdisplay.3.5.5 @kronprod/displayZlinear-algebra.html#g_t_0040kronprod_002ffull(3.5.6 @kronprod/fullXlinear-algebra.html#g_t_0040kronprod_002finv&3.5.7 @kronprod/invdlinear-algebra.html#g_t_0040kronprod_002fiscomplex23.5.8 @kronprod/iscomplexblinear-algebra.html#g_t_0040kronprod_002fismatrix03.5.9 @kronprod/ismatrix^linear-algebra.html#g_t_0040kronprod_002fisreal.3.5.10 @kronprod/isrealblinear-algebra.html#g_t_0040kronprod_002fissparse23.5.11 @kronprod/issparseblinear-algebra.html#g_t_0040kronprod_002fissquare23.5.12 @kronprod/issquareblinear-algebra.html#g_t_0040kronprod_002fkronprod23.5.13 @kronprod/kronprod\linear-algebra.html#g_t_0040kronprod_002fminus,3.5.14 @kronprod/minusblinear-algebra.html#g_t_0040kronprod_002fmldivide23.5.15 @kronprod/mldivide^linear-algebra.html#g_t_0040kronprod_002fmpower.3.5.16 @kronprod/mpower^linear-algebra.html#g_t_0040kronprod_002fmtimes.3.5.17 @kronprod/mtimes\linear-algebra.html#g_t_0040kronprod_002fnumel,3.5.18 @kronprod/numelZlinear-algebra.html#g_t_0040kronprod_002fplus*3.5.19 @kronprod/plusZlinear-algebra.html#g_t_0040kronprod_002frank*3.5.20 @kronprod/rank`linear-algebra.html#g_t_0040kronprod_002frdivide03.5.21 @kronprod/rdivideZlinear-algebra.html#g_t_0040kronprod_002frows*3.5.22 @kronprod/rowsZlinear-algebra.html#g_t_0040kronprod_002fsize*3.5.23 @kronprod/sizenlinear-algebra.html#g_t_0040kronprod_002fsize_005fequal63.5.24 @kronprod/size_equal^linear-algebra.html#g_t_0040kronprod_002fsparse.3.5.25 @kronprod/sparse\linear-algebra.html#g_t_0040kronprod_002ftimes,3.5.26 @kronprod/times\linear-algebra.html#g_t_0040kronprod_002ftrace,3.5.27 @kronprod/tracedlinear-algebra.html#g_t_0040kronprod_002ftranspose43.5.28 @kronprod/transpose^linear-algebra.html#g_t_0040kronprod_002fuminus.3.5.29 @kronprod/uminus\linear-algebra.html#g_t_0040kronprod_002fuplus,3.5.30 @kronprod/uplusLlinear-algebra.html#Circulant-matrices,3.6 Circulant matricesJlinear-algebra.html#circulant_005feig&3.6.1 circulant_eigJlinear-algebra.html#circulant_005finv&3.6.2 circulant_invblinear-algebra.html#circulant_005fmake_005fmatrix63.6.3 circulant_make_matrix~linear-algebra.html#circulant_005fmatrix_005fvector_005fproductJ3.6.4 circulant_matrix_vector_productlinear-algebra-2.2.4/doc/PaxHeaders/mkqhcp.py0000644000000000000000000000006215146653315016057 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/doc/mkqhcp.py0000755000175000017500000001331315146653315016377 0ustar00philipphilip#!/usr/bin/python3 ## mkqhcp.py ## Version 1.0.4 ## Copyright 2022-2026 John Donoghue ## ## This program is free software: you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see ## . import sys import os import re def process(name): with open(name + ".qhcp", 'wt') as f: f.write ('\n') f.write ('\n') f.write (' \n') f.write (' \n') f.write (' \n') f.write (' {0}.qhp\n'.format(name)) f.write (' {0}.qch\n'.format(name)) f.write (' \n') f.write (' \n') f.write (' \n') f.write (' {0}.qch\n'.format(name)) f.write (' \n') f.write (' \n') f.write ('\n') title = name pat_match = re.compile(r".*(?P<title>[^<]+).*") with open(name + ".html", 'rt') as fin: # find html for line in fin: line = line.strip() e = pat_match.match(line) if e: title = e.group("title") break # section h2_match = re.compile(r'.*

]*>(?P[^<]+)</h2>.*') # appendix h2a_match = re.compile(r'.*<h2 class="appendix"[^>]*>(?P<title>[^<]+)</h2>.*') # index h2i_match = re.compile(r'.*<h2 class="unnumbered"[^>]*>(?P<title>[^<]+)</h2>.*') h3_match = re.compile(r'.*<h3 class="section"[^>]*>(?P<title>[^<]+)</h3>.*') h4_match = re.compile(r'.*<h4 class="subsection"[^>]*>(?P<title>[^<]+)</h4>.*') tag_match1 = re.compile(r'.*<span id="(?P<tag>[^"]+)"[^>]*></span>.*') #tag_match2 = re.compile(r'.*<div class="[sub]*section" id="(?P<tag>[^"]+)"[^>]*>.*') tag_match2 = re.compile(r'.*<div class="[sub]*section[^"]*" id="(?P<tag>[^"]+)"[^>]*>.*') tag_match3 = re.compile(r'.*<div class="chapter-level-extent" id="(?P<tag>[^"]+)"[^>]*>.*') tag_match4 = re.compile(r'.*<div class="appendix-level-extent" id="(?P<tag>[^"]+)"[^>]*>.*') tag_match5 = re.compile(r'.*<div class="unnumbered-level-extent" id="(?P<tag>[^"]+)"[^>]*>.*') index_match = re.compile(r'.*<h4 class="subsection"[^>]*>[\d\.\s]*(?P<name>[^<]+)</h4>.*') tag = "top" has_h2 = False has_h3 = False #pat_match = re.compile(r'.*<span id="(?P<tag>[^"])"></span>(?P<title>[.]+)$') with open(name + ".html", 'rt') as fin: with open(name + ".qhp", 'wt') as f: f.write('<?xml version="1.0" encoding="UTF-8"?>\n') f.write('<QtHelpProject version="1.0">\n') f.write(' <namespace>octave.community.{}</namespace>\n'.format(name)) f.write(' <virtualFolder>doc</virtualFolder>\n') f.write(' <filterSection>\n') f.write(' <toc>\n') f.write(' <section title="{} Manual" ref="{}.html">\n'.format(title, name)) # chapters here for line in fin: line = line.strip() e = tag_match1.match(line) if not e: e = tag_match2.match(line) if not e: e = tag_match3.match(line) if not e: e = tag_match4.match(line) if not e: e = tag_match5.match(line) if e: tag = e.group("tag") e = h2_match.match(line) if not e: e = h2a_match.match(line) if not e: e = h2i_match.match(line) if e: if has_h3: f.write(' </section>\n') has_h3 = False if has_h2: f.write(' </section>\n') has_h2 = True f.write(' <section title="{}" ref="{}.html#{}">\n'.format(e.group("title"), name, tag)) e = h3_match.match(line) if e: if has_h3: f.write(' </section>\n') has_h3 = True f.write(' <section title="{}" ref="{}.html#{}">\n'.format(e.group("title"), name, tag)) e = h4_match.match(line) if e: f.write(' <section title="{}" ref="{}.html#{}"></section>\n'.format(e.group("title"), name, tag)) if has_h3: f.write(' </section>\n') if has_h2: f.write(' </section>\n') f.write(' </section>\n') f.write(' </toc>\n') f.write(' <keywords>\n') fin.seek(0) for line in fin: line = line.strip() e = tag_match1.match(line) if not e: e = tag_match2.match(line) if e: tag = e.group("tag") e = index_match.match(line) if e: f.write(' <keyword name="{}" ref="{}.html#{}"></keyword>\n'.format(e.group("name"), name, tag)) f.write(' </keywords>\n') f.write(' <files>\n') f.write(' <file>{}.html</file>\n'.format(name)) f.write(' <file>{}.css</file>\n'.format(name)) f.write(' </files>\n') f.write(' </filterSection>\n') f.write('</QtHelpProject>\n') def show_usage(): print (sys.argv[0], "projname") if __name__ == "__main__": if len(sys.argv) > 1: status = process(sys.argv[1]) sys.exit(status) else: show_usage() ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������linear-algebra-2.2.4/doc/PaxHeaders/functions.texi��������������������������������������������������0000644�0000000�0000000�00000000062�15146653315�017125� x����������������������������������������������������������������������������������������������������ustar�00�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������20 atime=1771787981 30 ctime=1771788142.228370636 ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������linear-algebra-2.2.4/doc/functions.texi�������������������������������������������������������������0000644�0001750�0001750�00000127712�15146653315�017453� 0����������������������������������������������������������������������������������������������������ustar�00philip��������������������������philip�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������@c --------------------------------------------------- @node Vector functions @section Vector functions @cindex Vector functions @c Vector functions vec_projection @c ----------------------------------------- @subsection vec_projection @cindex vec_projection @deftypefn {Function File} {@var{out} =} vec_projection (@var{x}, @var{y}) Compute the vector projection of a 3-vector onto another. @var{x} : size 1 x 3 and @var{y} : size 1 x 3 @var{tol} : size 1 x 1 @example vec_projection ([1,0,0], [0.5,0.5,0]) @result{} 0.7071 @end example Vector projection of @var{x} onto @var{y}, both are 3-vectors, returning the value of @var{x} along @var{y}. Function uses dot product, Euclidean norm, and angle between vectors to compute the proper length along @var{y}. @end deftypefn @c --------------------------------------------------- @node Matrix functions @section Matrix functions @cindex Matrix functions @c Matrix functions cartprod @c ----------------------------------------- @subsection cartprod @cindex cartprod @deftypefn {Function File} {} cartprod (@var{varargin}) Computes the cartesian product of given column vectors ( row vectors ). The vector elements are assumend to be numbers. Alternatively the vectors can be specified by as a matrix, by its columns. To calculate the cartesian product of vectors, P = A x B x C x D ... . Requires A, B, C, D be column vectors. The algorithm is iteratively calcualte the products, ( ( (A x B ) x C ) x D ) x etc. @example @group cartprod(1:2,3:4,0:1) ans = 1 3 0 2 3 0 1 4 0 2 4 0 1 3 1 2 3 1 1 4 1 2 4 1 @end group @end example @end deftypefn @xseealso{kron} @c Matrix functions cod @c ----------------------------------------- @subsection cod @cindex cod @deftypefn{Function File} {[@var{q}, @var{r}, @var{z}] =} cod (@var{a}) @deftypefnx{Function File} {[@var{q}, @var{r}, @var{z}, @var{p}] =} cod (@var{a}) @deftypefnx{Function File} {[@dots{}] =} cod (@var{a}, '0') Computes the complete orthogonal decomposition (COD) of the matrix @var{a}: @example @var{a} = @var{q}*@var{r}*@var{z}' @end example Let @var{a} be an M-by-N matrix, and let @code{K = min(M, N)}. Then @var{q} is M-by-M orthogonal, @var{z} is N-by-N orthogonal, and @var{r} is M-by-N such that @code{@var{r}(:,1:K)} is upper trapezoidal and @code{@var{r}(:,K+1:N)} is zero. The additional @var{p} output argument specifies that pivoting should be used in the first step (QR decomposition). In this case, @example @var{a}*@var{p} = @var{q}*@var{r}*@var{z}' @end example If a second argument of '0' is given, an economy-sized factorization is returned so that @var{r} is K-by-K. @emph{NOTE}: This is currently implemented by double QR factorization plus some tricky manipulations, and is not as efficient as using xRZTZF from LAPACK. @xseealso{qr} @end deftypefn @c Matrix functions funm @c ----------------------------------------- @subsection funm @cindex funm @deftypefn {Function File} {@var{B} =} funm (@var{A}, @var{F}) Compute matrix equivalent of function F; F can be a function name or a function handle and A must be a square matrix. For trigonometric and hyperbolic functions, @code{thfm} is automatically invoked as that is based on @code{expm} and diagonalization is avoided. For other functions diagonalization is invoked, which implies that -depending on the properties of input matrix @var{A}- the results can be very inaccurate @emph{without any warning}. For easy diagonizable and stable matrices the results of funm will be sufficiently accurate. Note that you should not use funm for 'sqrt', 'log' or 'exp'; instead use sqrtm, logm and expm as these are more robust. Examples: @example B = funm (A, sin); (Compute matrix equivalent of sin() ) @end example @example function bk1 = besselk1 (x) bk1 = besselk(1, x); endfunction B = funm (A, besselk1); (Compute matrix equivalent of bessel function K1(); a helper function is needed here to convey extra arguments for besselk() ) @end example Note that a much improved funm.m function has been implemented in Octave 11.1.0, so funm.m will be removed from the linear-algebra package if that is installed in Octave 11+. @xseealso{thfm, expm, logm, sqrtm} @end deftypefn @c Matrix functions lobpcg @c ----------------------------------------- @subsection lobpcg @cindex lobpcg @deftypefn {Function File} {[@var{blockVectorX}, @var{lambda}] =} lobpcg (@var{blockVectorX}, @var{operatorA}) @deftypefnx {Function File} {[@var{blockVectorX}, @var{lambda}, @var{failureFlag}] =} lobpcg (@var{blockVectorX}, @var{operatorA}) @deftypefnx {Function File} {[@var{blockVectorX}, @var{lambda}, @var{failureFlag}, @var{lambdaHistory}, @var{residualNormsHistory}] =} lobpcg (@var{blockVectorX}, @var{operatorA}, @var{operatorB}, @var{operatorT}, @var{blockVectorY}, @var{residualTolerance}, @var{maxIterations}, @var{verbosityLevel}) Solves Hermitian partial eigenproblems using preconditioning. The first form outputs the array of algebraic smallest eigenvalues @var{lambda} and corresponding matrix of orthonormalized eigenvectors @var{blockVectorX} of the Hermitian (full or sparse) operator @var{operatorA} using input matrix @var{blockVectorX} as an initial guess, without preconditioning, somewhat similar to: @example # for real symmetric operator operatorA opts.issym = 1; opts.isreal = 1; K = size (blockVectorX, 2); [blockVectorX, lambda] = eigs (operatorA, K, 'SR', opts); # for Hermitian operator operatorA K = size (blockVectorX, 2); [blockVectorX, lambda] = eigs (operatorA, K, 'SR'); @end example The second form returns a convergence flag. If @var{failureFlag} is 0 then all the eigenvalues converged; otherwise not all converged. The third form computes smallest eigenvalues @var{lambda} and corresponding eigenvectors @var{blockVectorX} of the generalized eigenproblem Ax=lambda Bx, where Hermitian operators @var{operatorA} and @var{operatorB} are given as functions, as well as a preconditioner, @var{operatorT}. The operators @var{operatorB} and @var{operatorT} must be in addition @emph{positive definite}. To compute the largest eigenpairs of @var{operatorA}, simply apply the code to @var{operatorA} multiplied by -1. The code does not involve @emph{any} matrix factorizations of @var{operatorA} and @var{operatorB}, thus, e.g., it preserves the sparsity and the structure of @var{operatorA} and @var{operatorB}. @var{residualTolerance} and @var{maxIterations} control tolerance and max number of steps, and @var{verbosityLevel} = 0, 1, or 2 controls the amount of printed info. @var{lambdaHistory} is a matrix with all iterative lambdas, and @var{residualNormsHistory} are matrices of the history of 2-norms of residuals Required input: @itemize @bullet @item @var{blockVectorX} (class numeric) - initial approximation to eigenvectors, full or sparse matrix n-by-blockSize. @var{blockVectorX} must be full rank. @item @var{operatorA} (class numeric, char, or function_handle) - the main operator of the eigenproblem, can be a matrix, a function name, or handle @end itemize Optional function input: @itemize @bullet @item @var{operatorB} (class numeric, char, or function_handle) - the second operator, if solving a generalized eigenproblem, can be a matrix, a function name, or handle; by default if empty, @code{operatorB = I}. @item @var{operatorT} (class char or function_handle) - the preconditioner, by default @code{operatorT(blockVectorX) = blockVectorX}. @end itemize Optional constraints input: @itemize @bullet @item @var{blockVectorY} (class numeric) - a full or sparse n-by-sizeY matrix of constraints, where sizeY < n. @var{blockVectorY} must be full rank. The iterations will be performed in the (operatorB-) orthogonal complement of the column-space of @var{blockVectorY}. @end itemize Optional scalar input parameters: @itemize @bullet @item @var{residualTolerance} (class numeric) - tolerance, by default, @code{residualTolerance = n * sqrt (eps)} @item @var{maxIterations} - max number of iterations, by default, @code{maxIterations = min (n, 20)} @item @var{verbosityLevel} - either 0 (no info), 1, or 2 (with pictures); by default, @code{verbosityLevel = 0}. @end itemize Required output: @itemize @bullet @item @var{blockVectorX} and @var{lambda} (class numeric) both are computed blockSize eigenpairs, where @code{blockSize = size (blockVectorX, 2)} for the initial guess @var{blockVectorX} if it is full rank. @end itemize Optional output: @itemize @bullet @item @var{failureFlag} (class integer) as described above. @item @var{lambdaHistory} (class numeric) as described above. @item @var{residualNormsHistory} (class numeric) as described above. @end itemize Functions @code{operatorA(blockVectorX)}, @code{operatorB(blockVectorX)} and @code{operatorT(blockVectorX)} must support @var{blockVectorX} being a matrix, not just a column vector. Every iteration involves one application of @var{operatorA} and @var{operatorB}, and one of @var{operatorT}. Main memory requirements: 6 (9 if @code{isempty(operatorB)=0}) matrices of the same size as @var{blockVectorX}, 2 matrices of the same size as @var{blockVectorY} (if present), and two square matrices of the size 3*blockSize. In all examples below, we use the Laplacian operator in a 20x20 square with the mesh size 1 which can be generated in MATLAB by running: @example A = delsq (numgrid ('S', 21)); n = size (A, 1); @end example or in MATLAB and Octave by: @example [~,~,A] = laplacian ([19, 19]); n = size (A, 1); @end example Note that @code{laplacian} is a function of the specfun octave-forge package. The following Example: @example [blockVectorX, lambda, failureFlag] = lobpcg (randn (n, 8), A, 1e-5, 50, 2); @end example attempts to compute 8 first eigenpairs without preconditioning, but not all eigenpairs converge after 50 steps, so failureFlag=1. The next Example: @example blockVectorY = []; lambda_all = []; for j = 1:4 [blockVectorX, lambda] = lobpcg (randn (n, 2), A, blockVectorY, 1e-5, 200, 2); blockVectorY = [blockVectorY, blockVectorX]; lambda_all = [lambda_all' lambda']'; pause; end @end example attemps to compute the same 8 eigenpairs by calling the code 4 times with blockSize=2 using orthogonalization to the previously founded eigenvectors. The following Example: @example R = ichol (A, struct('michol', 'on')); precfun = @@(x)R\(R'\x); [blockVectorX, lambda, failureFlag] = lobpcg (randn (n, 8), A, [], @@(x)precfun(x), 1e-5, 60, 2); @end example computes the same eigenpairs in less then 25 steps, so that failureFlag=0 using the preconditioner function @code{precfun}, defined inline. If @code{precfun} is defined as an octave function in a file, the function handle @code{@@(x)precfun(x)} can be equivalently replaced by the function name @code{precfun}. Running: @example [blockVectorX, lambda, failureFlag] = lobpcg (randn (n, 8), A, speye (n), @@(x)precfun(x), 1e-5, 50, 2); @end example produces similar answers, but is somewhat slower and needs more memory as technically a generalized eigenproblem with B=I is solved here. The following example for a mostly diagonally dominant sparse matrix A demonstrates different types of preconditioning, compared to the standard use of the main diagonal of A: @example clear all; close all; n = 1000; M = spdiags ([1:n]', 0, n, n); precfun = @@(x)M\x; A = M + sprandsym (n, .1); Xini = randn (n, 5); maxiter = 15; tol = 1e-5; [~,~,~,~,rnp] = lobpcg (Xini, A, tol, maxiter, 1); [~,~,~,~,r] = lobpcg (Xini, A, [], @@(x)precfun(x), tol, maxiter, 1); subplot (2,2,1), semilogy (r'); hold on; semilogy (rnp', ':>'); title ('No preconditioning (top)'); axis tight; M(1,2) = 2; precfun = @@(x)M\x; % M is no longer symmetric [~,~,~,~,rns] = lobpcg (Xini, A, [], @@(x)precfun(x), tol, maxiter, 1); subplot (2,2,2), semilogy (r'); hold on; semilogy (rns', '--s'); title ('Nonsymmetric preconditioning (square)'); axis tight; M(1,2) = 0; precfun = @@(x)M\(x+10*sin(x)); % nonlinear preconditioning [~,~,~,~,rnl] = lobpcg (Xini, A, [], @@(x)precfun(x), tol, maxiter, 1); subplot (2,2,3), semilogy (r'); hold on; semilogy (rnl', '-.*'); title ('Nonlinear preconditioning (star)'); axis tight; M = abs (M - 3.5 * speye (n, n)); precfun = @@(x)M\x; [~,~,~,~,rs] = lobpcg (Xini, A, [], @@(x)precfun(x), tol, maxiter, 1); subplot (2,2,4), semilogy (r'); hold on; semilogy (rs', '-d'); title ('Selective preconditioning (diamond)'); axis tight; @end example @heading References This main function @code{lobpcg} is a version of the preconditioned conjugate gradient method (Algorithm 5.1) described in A. V. Knyazev, Toward the Optimal Preconditioned Eigensolver: Locally Optimal Block Preconditioned Conjugate Gradient Method, SIAM Journal on Scientific Computing 23 (2001), no. 2, pp. 517-541. @uref{http://dx.doi.org/10.1137/S1064827500366124} @heading Known bugs/features @itemize @bullet @item an excessively small requested tolerance may result in often restarts and instability. The code is not written to produce an eps-level accuracy! Use common sense. @item the code may be very sensitive to the number of eigenpairs computed, if there is a cluster of eigenvalues not completely included, cf. @example operatorA = diag ([1 1.99 2:99]); [blockVectorX, lambda] = lobpcg (randn (100, 1),operatorA, 1e-10, 80, 2); [blockVectorX, lambda] = lobpcg (randn (100, 2),operatorA, 1e-10, 80, 2); [blockVectorX, lambda] = lobpcg (randn (100, 3),operatorA, 1e-10, 80, 2); @end example @end itemize @heading Distribution The main distribution site: @uref{http://math.ucdenver.edu/~aknyazev/} A C-version of this code is a part of the @uref{http://code.google.com/p/blopex/} package and is directly available, e.g., in PETSc and HYPRE. @end deftypefn @c Matrix functions ndcovlt @c ----------------------------------------- @subsection ndcovlt @cindex ndcovlt @deftypefn{Function File} {@var{y} =} ndcovlt (@var{x}, @var{t1}, @var{t2}, @dots{}) Computes an n-dimensional covariant linear transform of an n-d tensor, given a transformation matrix for each dimension. The number of columns of each transformation matrix must match the corresponding extent of @var{x}, and the number of rows determines the corresponding extent of @var{y}. For example: @example size (@var{x}, 2) == columns (@var{t2}) size (@var{y}, 2) == rows (@var{t2}) @end example The element @code{@var{y}(i1, i2, @dots{})} is defined as a sum of @example @var{x}(j1, j2, @dots{}) * @var{t1}(i1, j1) * @var{t2}(i2, j2) * @dots{} @end example over all j1, j2, @dots{}. For two dimensions, this reduces to @example @var{y} = @var{t1} * @var{x} * @var{t2}.' @end example [] passed as a transformation matrix is converted to identity matrix for the corresponding dimension. @end deftypefn @c Matrix functions rotparams @c ----------------------------------------- @subsection rotparams @cindex rotparams @deftypefn{Function File} {[@var{vstacked}, @var{astacked}] =} rotparams (@var{rstacked}) The function w = rotparams (r) - Inverse to rotv(). Using, @var{w} = rotparams(@var{r}) is such that rotv(w)*r' == eye(3). If used as, [v,a]=rotparams(r) , idem, with v (1 x 3) s.t. w == a*v. 0 <= norm(w)==a <= pi :-O !! Does not check if 'r' is a rotation matrix. Ignores matrices with zero rows or with NaNs. (returns 0 for them) @xseealso{rotv} @end deftypefn @c Matrix functions rotv @c ----------------------------------------- @subsection rotv @cindex rotv @deftypefn{Function File} {@var{r} = } rotv ( v, ang ) The functionrotv calculates a Matrix of rotation about @var{v} w/ angle |v| r = rotv(v [,ang]) Returns the rotation matrix w/ axis v, and angle, in radians, norm(v) or ang (if present). rotv(v) == w'*w + cos(a) * (eye(3)-w'*w) - sin(a) * crossmat(w) where a = norm (v) and w = v/a. v and ang may be vertically stacked : If 'v' is 2x3, then rotv( v ) == [rotv(v(1,:)); rotv(v(2,:))] @xseealso{rotparams, rota, rot} @end deftypefn @c Matrix functions smwsolve @c ----------------------------------------- @subsection smwsolve @cindex smwsolve @deftypefn{Function File} {@var{x} =} smwsolve (@var{a}, @var{u}, @var{v}, @var{b}) @deftypefnx{Function File} {} smwsolve (@var{solver}, @var{u}, @var{v}, @var{b}) Solves the square system @code{(A + U*V')*X == B}, where @var{u} and @var{v} are matrices with several columns, using the Sherman-Morrison-Woodbury formula, so that a system with @var{a} as left-hand side is actually solved. This is especially advantageous if @var{a} is diagonal, sparse, triangular or positive definite. @var{a} can be sparse or full, the other matrices are expected to be full. Instead of a matrix @var{a}, a user may alternatively provide a function @var{solver} that performs the left division operation. @end deftypefn @c Matrix functions thfm @c ----------------------------------------- @subsection thfm @cindex thfm @deftypefn{Function File} {@var{y} =} thfm (@var{x}, @var{mode}) Trigonometric/hyperbolic functions of square matrix @var{x}. @var{mode} must be the name of a function. Valid functions are 'sin', 'cos', 'tan', 'sec', 'csc', 'cot' and all their inverses and/or hyperbolic variants, and 'sqrt', 'log' and 'exp'. The code @code{thfm (x, 'cos')} calculates matrix cosinus @emph{even if} input matrix @var{x} is @emph{not} diagonalizable. @emph{Important note}: This algorithm does @emph{not} use an eigensystem similarity transformation. It maps the @var{mode} functions to functions of @code{expm}, @code{logm} and @code{sqrtm}, which are known to be robust with respect to non-diagonalizable ('defective') @var{x}. @xseealso{funm} @end deftypefn @c --------------------------------------------------- @node Matrix factorization @section Matrix factorization @cindex Matrix factorization @c Matrix factorization nmf_bpas @c ----------------------------------------- @subsection nmf_bpas @cindex nmf_bpas @deftypefn {Function File} {[@var{W}, @var{H}, @var{iter}, @var{HIS}] = } nmf_bpas (@var{A}, @var{k}) Nonnegative Matrix Factorization by Alternating Nonnegativity Constrained Least Squares using Block Principal Pivoting/Active Set method. This function solves one the following problems: given @var{A} and @var{k}, find @var{W} and @var{H} such that @group (1) minimize 1/2 * || @var{A}-@var{W}@var{H} ||_F^2 (2) minimize 1/2 * ( || @var{A}-@var{W}@var{H} ||_F^2 + alpha * || @var{W} ||_F^2 + beta * || @var{H} ||_F^2 ) (3) minimize 1/2 * ( || @var{A}-@var{W}@var{H} ||_F^2 + alpha * || @var{W} ||_F^2 + beta * (sum_(i=1)^n || @var{H}(:,i) ||_1^2 ) ) @end group where @var{W}>=0 and @var{H}>=0 elementwise. The input arguments are @var{A} : Input data matrix (m x n) and @var{k} : Target low-rank. @strong{Optional Inputs} @table @samp @item Type Default is 'regularized', which is recommended for quick application testing unless 'sparse' or 'plain' is explicitly needed. If sparsity is needed for 'W' factor, then apply this function for the transpose of 'A' with formulation (3). Then, exchange 'W' and 'H' and obtain the transpose of them. Imposing sparsity for both factors is not recommended and thus not included in this software. @table @asis @item 'plain' to use formulation (1) @item 'regularized' to use formulation (2) @item 'sparse' to use formulation (3) @end table @item NNLSSolver Default is 'bp', which is in general faster. @table @asis @item 'bp' to use the algorithm in [1] @item 'as' to use the algorithm in [2] @end table @item Alpha Parameter alpha in the formulation (2) or (3). Default is the average of all elements in A. No good justfication for this default value, and you might want to try other values. @item Beta Parameter beta in the formulation (2) or (3). Default is the average of all elements in A. No good justfication for this default value, and you might want to try other values. @item MaxIter Maximum number of iterations. Default is 100. @item MinIter Minimum number of iterations. Default is 20. @item MaxTime Maximum amount of time in seconds. Default is 100,000. @item Winit (m x k) initial value for W. @item Hinit (k x n) initial value for H. @item Tol Stopping tolerance. Default is 1e-3. If you want to obtain a more accurate solution, decrease TOL and increase MAX_ITER at the same time. @item Verbose If present the function will show information during the calculations. @end table @strong{Outputs} @table @samp @item W Obtained basis matrix (m x k) @item H Obtained coefficients matrix (k x n) @item iter Number of iterations @item HIS If present the history of computation is returned. @end table Usage Examples: @example nmf_bpas (A,10) nmf_bpas (A,20,'verbose') nmf_bpas (A,30,'verbose','nnlssolver','as') nmf_bpas (A,5,'verbose','type','sparse') nmf_bpas (A,60,'verbose','type','plain','Winit',rand(size(A,1),60)) nmf_bpas (A,70,'verbose','type','sparse','nnlssolver','bp','alpha',1.1,'beta',1.3) @end example References: [1] For using this software, please cite:@* Jingu Kim and Haesun Park, Toward Faster Nonnegative Matrix Factorization: A New Algorithm and Comparisons,@* In Proceedings of the 2008 Eighth IEEE International Conference on Data Mining (ICDM'08), 353-362, 2008@* [2] If you use 'nnls_solver'='as' (see below), please cite:@* Hyunsoo Kim and Haesun Park, Nonnegative Matrix Factorization Based @* on Alternating Nonnegativity Constrained Least Squares and Active Set Method, @* SIAM Journal on Matrix Analysis and Applications, 2008, 30, 713-730 Check original code at @url{http://www.cc.gatech.edu/~jingu} @xseealso{nmf_pg} @end deftypefn @c Matrix factorization nmf_pg @c ----------------------------------------- @subsection nmf_pg @cindex nmf_pg @deftypefn {Function File} {[@var{W}, @var{H}] =} nmf_pg (@var{V}, @var{Winit}, @ @var{Hinit}, @var{tol}, @var{timelimit}, @var{maxiter}) Non-negative matrix factorization by alternative non-negative least squares using projected gradients. The matrix @var{V} is factorized into two possitive matrices @var{W} and @var{H} such that @code{V = W*H + U}. Where @var{U} is a matrix of residuals that can be negative or positive. When the matrix @var{V} is positive the order of the elements in @var{U} is bounded by the optional named argument @var{tol} (default value @code{1e-9}). The factorization is not unique and depends on the inital guess for the matrices @var{W} and @var{H}. You can pass this initalizations using the optional named arguments @var{Winit} and @var{Hinit}. timelimit, maxiter: limit of time and iterations Examples: @example A = rand(10,5); [W H] = nmf_pg(A,tol=1e-3); U = W*H -A; disp(max(abs(U))); @end example @end deftypefn @c --------------------------------------------------- @node Block sparse matrices @section Block sparse matrices @cindex Block sparse matrices @c Block sparse matrices @blksparse/blksize @c ----------------------------------------- @subsection @@blksparse/blksize @cindex blksize @deftypefn {Function File} blksize (@var{x}) Returns the block size of the matrix. @end deftypefn @c Block sparse matrices @blksparse/blksparse @c ----------------------------------------- @subsection @@blksparse/blksparse @cindex blksparse @deftypefn{Function File} {@var{s} =} blksparse (@var{i}, @var{j}, @var{sv}) @deftypefnx{Function File} {@var{s} =} blksparse (@var{i}, @var{j}, @var{sv}, @var{m}, @var{n}) @deftypefnx{Function File} {@var{s} =} blksparse (@dots{}, @var{mode}) Construct a block sparse matrix. The meaning of arguments is analogous to the built-in @code{sparse} function, except that @var{i}, @var{j} are indices of blocks rather than elements, and @var{sv} is a 3-dimensional array, the first two dimensions determining the block size. Optionally, @var{m} and @var{n} can be specified as the true block dimensions; if not, the maximum values of @var{i}, @var{j} are taken instead. The resulting sparse matrix has the size @example [@var{m}*@var{p}, @var{n}*@var{q}] @end example where @example @var{p} = size (@var{sv}, 1) @var{q} = size (@var{sv}, 2) @end example The blocks are located so that @example @var{s}(@var{i}(k):@var{i}(k)+@var{p}-1, @var{j}(k):@var{j}(K)+@var{q}-1) = @var{sv}(:,:,k) @end example Multiple blocks corresponding to the same pair of indices are summed, unless @var{mode} is "unique", in which case the last of them is used. @end deftypefn @c Block sparse matrices @blksparse/ctranspose @c ----------------------------------------- @subsection @@blksparse/ctranspose @cindex ctranspose @deftypefn {Function File} ctranspose (@var{x}) Returns the conjugate transpose of a block sparse matrix @var{x}. @end deftypefn @c Block sparse matrices @blksparse/display @c ----------------------------------------- @subsection @@blksparse/display @cindex display @deftypefn {Function File} display (@var{x}) Displays the block sparse matrix. @end deftypefn @c Block sparse matrices @blksparse/full @c ----------------------------------------- @subsection @@blksparse/full @cindex full @deftypefn {Function File} full (@var{x}) Converts a block sparse matrix to full. @end deftypefn @c Block sparse matrices @blksparse/ismatrix @c ----------------------------------------- @subsection @@blksparse/ismatrix @cindex ismatrix @deftypefn {Function File} ismatrix (@var{s}) Returns true (a blksparse object is a matrix). @end deftypefn @c Block sparse matrices @blksparse/isreal @c ----------------------------------------- @subsection @@blksparse/isreal @cindex isreal @deftypefn {Function File} isreal (@var{s}) Returns true if the array is non-complex. @end deftypefn @c Block sparse matrices @blksparse/issparse @c ----------------------------------------- @subsection @@blksparse/issparse @cindex issparse @deftypefn {Function File} issparse (@var{s}) Returns true since a blksparse is sparse by definition. @end deftypefn @c Block sparse matrices @blksparse/minus @c ----------------------------------------- @subsection @@blksparse/minus @cindex minus @deftypefn {Function File} minus (@var{s1}, @var{s2}) Subtract two blksparse objects. @end deftypefn @c Block sparse matrices @blksparse/mldivide @c ----------------------------------------- @subsection @@blksparse/mldivide @cindex mldivide @deftypefn {Function File} mldivide (@var{x}, @var{y}) Performs a left division with a block sparse matrix. If @var{x} is a block sparse matrix, it must be either diagonal or triangular, and @var{y} must be full. If @var{x} is built-in sparse or full, @var{y} is converted accordingly, then the built-in division is used. @end deftypefn @c Block sparse matrices @blksparse/mrdivide @c ----------------------------------------- @subsection @@blksparse/mrdivide @cindex mrdivide @deftypefn {Function File} mrdivide (@var{x}, @var{y}) Performs a left division with a block sparse matrix. If @var{y} is a block sparse matrix, it must be either diagonal or triangular, and @var{x} must be full. If @var{y} is built-in sparse or full, @var{x} is converted accordingly, then the built-in division is used. @end deftypefn @c Block sparse matrices @blksparse/mtimes @c ----------------------------------------- @subsection @@blksparse/mtimes @cindex mtimes @deftypefn {Function File} mtimes (@var{x}, @var{y}) Multiplies a block sparse matrix with a full matrix, or two block sparse matrices. Multiplication of block sparse * sparse is not implemented. If one of arguments is a scalar, it's a scalar multiply. @end deftypefn @c Block sparse matrices @blksparse/plus @c ----------------------------------------- @subsection @@blksparse/plus @cindex plus @deftypefn {Function File} plus (@var{s1}, @var{s2}) Add two blksparse objects. @end deftypefn @c Block sparse matrices @blksparse/size @c ----------------------------------------- @subsection @@blksparse/size @cindex size @deftypefn {Function File} size (@var{x}) Returns the size of the matrix. @end deftypefn @c Block sparse matrices @blksparse/sparse @c ----------------------------------------- @subsection @@blksparse/sparse @cindex sparse @deftypefn {Function File} sparse (@var{x}) Converts a block sparse matrix to (built-in) sparse. @end deftypefn @c Block sparse matrices @blksparse/subsref @c ----------------------------------------- @subsection @@blksparse/subsref @cindex subsref @deftypefn {Function File} subsref (@var{s}, @var{subs}) Index elements from a blksparse object. @end deftypefn @c Block sparse matrices @blksparse/transpose @c ----------------------------------------- @subsection @@blksparse/transpose @cindex transpose @deftypefn {Function File} transpose (@var{x}) Returns the transpose of a block sparse matrix @var{x}. @end deftypefn @c Block sparse matrices @blksparse/uminus @c ----------------------------------------- @subsection @@blksparse/uminus @cindex uminus @deftypefn {Function File} uminus (@var{x}) Returns the negative of a block sparse matrix @var{x}. @end deftypefn @c Block sparse matrices @blksparse/uplus @c ----------------------------------------- @subsection @@blksparse/uplus @cindex uplus @deftypefn {Function File} uplus (@var{x}) Returns the unary plus of a block sparse matrix @var{x}. Effectively the matrix itself, except signs of zeros. @end deftypefn @c --------------------------------------------------- @node Kronecker Products @section Kronecker Products @cindex Kronecker Products @c Kronecker Products @kronprod/columns @c ----------------------------------------- @subsection @@kronprod/columns @cindex columns @deftypefn {Function File} columns (@var{KP}) Return the number of columns in the Kronecker product @var{KP}. @xseealso{@@kronprod/rows, @@kronprod/size, @@kronprod/numel} @end deftypefn @c Kronecker Products @kronprod/ctranspose @c ----------------------------------------- @subsection @@kronprod/ctranspose @cindex ctranspose @deftypefn {Function File} ctranspose (@var{KP}) The complex conjugate transpose of a Kronecker product. This is equivalent to @example @var{KP}' @end example @xseealso{ctranspose, @@kronprod/transpose} @end deftypefn @c Kronecker Products @kronprod/det @c ----------------------------------------- @subsection @@kronprod/det @cindex det @deftypefn {Function File} det (@var{KP}) Compute the determinant of a Kronecker product. If @var{KP} is the Kronecker product of the @var{n}-by-@var{n} matrix @var{A} and the @var{q}-by-@var{q} matrix @var{B}, then the determinant is computed as @example det (@var{A})^q * det (@var{B})^n @end example If @var{KP} is not a Kronecker product of square matrices the determinant is computed by forming the full matrix and then computing the determinant. @xseealso{det, @@kronprod/trace, @@kronprod/rank, @@kronprod/full} @end deftypefn @c Kronecker Products @kronprod/disp @c ----------------------------------------- @subsection @@kronprod/disp @cindex disp @deftypefn {Function File} disp (@var{KP}) Show the content of the Kronecker product @var{KP}. To avoid evaluating the Kronecker product, this function displays the two matrices defining the product. To display the actual values of @var{KP}, use @code{disp (full (@var{KP}))}. This function is equivalent to @code{@@kronprod/display}. @xseealso{@@kronprod/display, @@kronprod/full} @end deftypefn @c Kronecker Products @kronprod/display @c ----------------------------------------- @subsection @@kronprod/display @cindex display @deftypefn {Function File} display (@var{KP}) Show the content of the Kronecker product @var{KP}. To avoid evaluating the Kronecker product, this function displays the two matrices defining the product. To display the actual values of @var{KP}, use @code{display (full (@var{KP}))}. @xseealso{@@kronprod/displ, @@kronprod/full} @end deftypefn @c Kronecker Products @kronprod/full @c ----------------------------------------- @subsection @@kronprod/full @cindex full @deftypefn {Function File} full (@var{KP}) Return the full matrix representation of the Kronecker product @var{KP}. If @var{KP} is the Kronecker product of an @var{n}-by-@var{m} matrix and a @var{q}-by-@var{r} matrix, then the result is a @var{n}@var{q}-by-@var{m}@var{r} matrix. Thus, the result can require vast amount of memory, so this function should be avoided whenever possible. @xseealso{full, @@kronprod/sparse} @end deftypefn @c Kronecker Products @kronprod/inv @c ----------------------------------------- @subsection @@kronprod/inv @cindex inv @deftypefn {Function File} inv (@var{KP}) Return the inverse of the Kronecker product @var{KP}. If @var{KP} is the Kronecker product of two square matrices @var{A} and @var{B}, the inverse will be computed as the Kronecker product of the inverse of @var{A} and @var{B}. If @var{KP} is square but not a Kronecker product of square matrices, the inverse will be computed using the SVD @xseealso{@@kronprod/sparse} @end deftypefn @c Kronecker Products @kronprod/iscomplex @c ----------------------------------------- @subsection @@kronprod/iscomplex @cindex iscomplex @deftypefn {Function File} iscomplex (@var{KP}) Return @t{true} if the Kronecker product @var{KP} contains any complex values. @xseealso{iscomplex, @@kronprod/isreal} @end deftypefn @c Kronecker Products @kronprod/ismatrix @c ----------------------------------------- @subsection @@kronprod/ismatrix @cindex ismatrix @deftypefn {Function File} ismatrix (@var{KP}) Return @t{true} to indicate that the Kronecker product @var{KP} always is a matrix. @end deftypefn @c Kronecker Products @kronprod/isreal @c ----------------------------------------- @subsection @@kronprod/isreal @cindex isreal @deftypefn {Function File} isreal (@var{KP}) Return @t{true} if the Kronecker product @var{KP} is real, i.e. has no imaginary components. @xseealso{isreal, @@kronprod/iscomplex} @end deftypefn @c Kronecker Products @kronprod/issparse @c ----------------------------------------- @subsection @@kronprod/issparse @cindex issparse @deftypefn {Function File} issparse (@var{KP}) Return @t{true} if one of the matrices in the Kronecker product @var{KP} is sparse. @xseealso{@@kronprod/sparse} @end deftypefn @c Kronecker Products @kronprod/issquare @c ----------------------------------------- @subsection @@kronprod/issquare @cindex issquare @deftypefn {Function File} issquare (@var{KP}) Return @t{true} if the Kronecker product @var{KP} is a square matrix. @xseealso{@@kronprod/size} @end deftypefn @c Kronecker Products @kronprod/kronprod @c ----------------------------------------- @subsection @@kronprod/kronprod @cindex kronprod @deftypefn {Function File} kronprod (@var{A}, @var{B}) @deftypefnx{Function File} kronprod (@var{A}, @var{B}, @var{P}) Construct a Kronecker product object. XXX: Write proper documentation With two input arguments, the following matrix is represented: kron (A, B); With three input arguments, the following matrix is represented: P * kron (A, B) * P' (P must be a permutation matrix) @end deftypefn @c Kronecker Products @kronprod/minus @c ----------------------------------------- @subsection @@kronprod/minus @cindex minus @deftypefn {Function File} minus (@var{a}, @var{a}) Return the difference between a Kronecker product and another matrix. This is performed by forming the full matrix of both inputs and is as such a potential expensive operation. @xseealso{minus, @@kronprod/plus} @end deftypefn @c Kronecker Products @kronprod/mldivide @c ----------------------------------------- @subsection @@kronprod/mldivide @cindex mldivide @deftypefn {Function File} mldivide (@var{M1}, @var{M2}) Perform matrix left division. @end deftypefn @c Kronecker Products @kronprod/mpower @c ----------------------------------------- @subsection @@kronprod/mpower @cindex mpower @deftypefn {Function File} mpower (@var{KP}, @var{k}) Perform matrix power operation. @end deftypefn @c Kronecker Products @kronprod/mtimes @c ----------------------------------------- @subsection @@kronprod/mtimes @cindex mtimes @deftypefn {Function File} mtimes (@var{KP1}, @var{KP2}) Perform matrix multiplication operation. @end deftypefn @c Kronecker Products @kronprod/numel @c ----------------------------------------- @subsection @@kronprod/numel @cindex numel @deftypefn {Function File} numel (@var{KP}) Return the number of elements in the Kronecker product @var{KP}. @xseealso{numel, @@kronprod/rows, @@kronprod/columns, @@kronprod/size} @end deftypefn @c Kronecker Products @kronprod/plus @c ----------------------------------------- @subsection @@kronprod/plus @cindex plus @deftypefn {Function File} plus (@var{a}, @var{a}) Return the sum of a Kronecker product and another matrix. This is performed by forming the full matrix of both inputs and is as such a potential expensive operation. @xseealso{plus, @@kronprod/minus} @end deftypefn @c Kronecker Products @kronprod/rank @c ----------------------------------------- @subsection @@kronprod/rank @cindex rank @deftypefn {Function File} rank (@var{KP}) Return the rank of the Kronecker product @var{KP}. This is computed as the product of the ranks of the matrices forming the product. @xseealso{rank, @@kronprod/det, @@kronprod/trace} @end deftypefn @c Kronecker Products @kronprod/rdivide @c ----------------------------------------- @subsection @@kronprod/rdivide @cindex rdivide @deftypefn {Function File} rdivide (@var{a}, @var{b}) Perform element-by-element right division. @end deftypefn @c Kronecker Products @kronprod/rows @c ----------------------------------------- @subsection @@kronprod/rows @cindex rows @deftypefn {Function File} rows (@var{KP}) Return the number of rows in the Kronecker product @var{KP}. @xseealso{rows, @@kronprod/size, @@kronprod/columns, @@kronprod/numel} @end deftypefn @c Kronecker Products @kronprod/size @c ----------------------------------------- @subsection @@kronprod/size @cindex size @deftypefn {Function File} size (@var{KP}) @deftypefnx{Function File} size (@var{KP}, @var{dim}) Return the size of the Kronecker product @var{KP} as a vector. @xseealso{size, @@kronprod/rows, @@kronprod/columns, @@kronprod/numel} @end deftypefn @c Kronecker Products @kronprod/size_equal @c ----------------------------------------- @subsection @@kronprod/size_equal @cindex size_equal @deftypefn {Function File} size_equal (@dots{}) True if all input have same dimensions. @end deftypefn @c Kronecker Products @kronprod/sparse @c ----------------------------------------- @subsection @@kronprod/sparse @cindex sparse @deftypefn {Function File} sparse (@var{KP}) Return the Kronecker product @var{KP} represented as a sparse matrix. @xseealso{sparse, @@kronprod/issparse, @@kronprod/full} @end deftypefn @c Kronecker Products @kronprod/times @c ----------------------------------------- @subsection @@kronprod/times @cindex times @deftypefn {Function File} times (@var{KP}, @var{KP2}) Perform elemtn-by-element multiplication. @end deftypefn @c Kronecker Products @kronprod/trace @c ----------------------------------------- @subsection @@kronprod/trace @cindex trace @deftypefn {Function File} trace (@var{KP}) Returns the trace of the Kronecker product @var{KP}. If @var{KP} is a Kronecker product of two square matrices, the trace is computed as the product of the trace of these two matrices. Otherwise the trace is computed by forming the full matrix. @xseealso{@@kronprod/det, @@kronprod/rank, @@kronprod/full} @end deftypefn @c Kronecker Products @kronprod/transpose @c ----------------------------------------- @subsection @@kronprod/transpose @cindex transpose @deftypefn {Function File} transpose (@var{KP}) Returns the transpose of the Kronecker product @var{KP}. This is equivalent to @example @var{KP}.' @end example @xseealso{transpose, @@kronprod/ctranspose} @end deftypefn @c Kronecker Products @kronprod/uminus @c ----------------------------------------- @subsection @@kronprod/uminus @cindex uminus @deftypefn {Function File} uminus (@var{KP}) Returns the unary minus operator working on the Kronecker product @var{KP}. This corresponds to @code{-@var{KP}} and simply returns the Kronecker product with the sign of the smallest matrix in the product reversed. @xseealso{@@kronprod/uminus} @end deftypefn @c Kronecker Products @kronprod/uplus @c ----------------------------------------- @subsection @@kronprod/uplus @cindex uplus @deftypefn {Function File} uplus (@var{KP}) Returns the unary plus operator working on the Kronecker product @var{KP}. This corresponds to @code{+@var{KP}} and simply returns the Kronecker product unchanged. @xseealso{@@kronprod/uminus} @end deftypefn @c --------------------------------------------------- @node Circulant matrices @section Circulant matrices @cindex Circulant matrices @c Circulant matrices circulant_eig @c ----------------------------------------- @subsection circulant_eig @cindex circulant_eig @deftypefn{Function File} {@var{lambda} =} circulant_eig (@var{v}) @deftypefnx{Function File} {[@var{vs}, @var{lambda}] =} circulant_eig (@var{v}) Fast, compact calculation of eigenvalues and eigenvectors of a circulant matrix@* Given an @var{n}*1 vector @var{v}, return the eigenvalues @var{lambda} and optionally eigenvectors @var{vs} of the @var{n}*@var{n} circulant matrix @var{C} that has @var{v} as its first column Theoretically same as @code{eig(make_circulant_matrix(v))}, but many fewer computations; does not form @var{C} explicitly Reference: Robert M. Gray, Toeplitz and Circulant Matrices: A Review, Now Publishers, http://ee.stanford.edu/~gray/toeplitz.pdf, Chapter 3 @xseealso{gallery, circulant_matrix_vector_product, circulant_inv} @end deftypefn @c Circulant matrices circulant_inv @c ----------------------------------------- @subsection circulant_inv @cindex circulant_inv @deftypefn{Function File} {@var{c} =} circulant_inv (@var{v}) Fast, compact calculation of inverse of a circulant matrix@* Given an @var{n}*1 vector @var{v}, return the inverse @var{c} of the @var{n}*@var{n} circulant matrix @var{C} that has @var{v} as its first column The returned @var{c} is the first column of the inverse, which is also circulant -- to get the full matrix, use `circulant_make_matrix(c)' Theoretically same as @code{inv(make_circulant_matrix(v))(:, 1)}, but requires many fewer computations and does not form matrices explicitly Roundoff may induce a small imaginary component in @var{c} even if @var{v} is real -- use @code{real(c)} to remedy this Reference: Robert M. Gray, Toeplitz and Circulant Matrices: A Review, Now Publishers, http://ee.stanford.edu/~gray/toeplitz.pdf, Chapter 3 @xseealso{gallery, circulant_matrix_vector_product, circulant_eig} @end deftypefn @c Circulant matrices circulant_make_matrix @c ----------------------------------------- @subsection circulant_make_matrix @cindex circulant_make_matrix @deftypefn{Function File} {@var{C} =} circulant_make_matrix (@var{v}) Produce a full circulant matrix given the first column. @emph{Note:} this function has been deprecated and will be removed in the future. Instead, use @code{gallery} with the the @code{circul} option. To obtain the exactly same matrix, transpose the result, i.e., replace @code{circulant_make_matrix (@var{v})} with @code{gallery ("circul", @var{v})'}. Given an @var{n}*1 vector @var{v}, returns the @var{n}*@var{n} circulant matrix @var{C} where @var{v} is the left column and all other columns are downshifted versions of @var{v}. Note: If the first row @var{r} of a circulant matrix is given, the first column @var{v} can be obtained as @code{v = r([1 end:-1:2])}. Reference: Gene H. Golub and Charles F. Van Loan, Matrix Computations, 3rd Ed., Section 4.7.7 @xseealso{gallery, circulant_matrix_vector_product, circulant_eig, circulant_inv} @end deftypefn @c Circulant matrices circulant_matrix_vector_product @c ----------------------------------------- @subsection circulant_matrix_vector_product @cindex circulant_matrix_vector_product @deftypefn{Function File} {@var{y} =} circulant_matrix_vector_product (@var{v}, @var{x}) Fast, compact calculation of the product of a circulant matrix with a vector@* Given @var{n}*1 vectors @var{v} and @var{x}, return the matrix-vector product @var{y} = @var{C}@var{x}, where @var{C} is the @var{n}*@var{n} circulant matrix that has @var{v} as its first column Theoretically the same as @code{make_circulant_matrix(x) * v}, but does not form @var{C} explicitly; uses the discrete Fourier transform Because of roundoff, the returned @var{y} may have a small imaginary component even if @var{v} and @var{x} are real (use @code{real(y)} to remedy this) Reference: Gene H. Golub and Charles F. Van Loan, Matrix Computations, 3rd Ed., Section 4.7.7 @xseealso{gallery, circulant_eig, circulant_inv} @end deftypefn ������������������������������������������������������linear-algebra-2.2.4/doc/PaxHeaders/linear-algebra.qch����������������������������������������������0000644�0000000�0000000�00000000062�15146653315�017564� x����������������������������������������������������������������������������������������������������ustar�00�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������20 atime=1771787981 30 ctime=1771788142.228370636 ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������linear-algebra-2.2.4/doc/linear-algebra.qch���������������������������������������������������������0000644�0001750�0001750�00000240000�15146653315�020074� 0����������������������������������������������������������������������������������������������������ustar�00philip��������������������������philip�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������SQLite format 3���@ �������������������������������������������������������������������.~Z ��� o�–«A $ § › 3 ½ ? É o�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������X''qtableMetaDataTableMetaDataTableCREATE TABLE MetaDataTable(Name Text, Value BLOB )t ##/tableFolderTableFolderTableCREATE TABLE FolderTable(Id INTEGER PRIMARY KEY, Name Text, NamespaceID INTEGER )| ''7tableFileNameTableFileNameTable CREATE TABLE FileNameTable (FolderId INTEGER, Name TEXT, FileId INTEGER, Title TEXT )t ++tableFileFilterTableFileFilterTable CREATE TABLE FileFilterTable (FilterAttributeId INTEGER, FileId INTEGER )f '' tableFileDataTableFileDataTable CREATE TABLE FileDataTable (Id INTEGER PRIMARY KEY, Data BLOB ) 77#tableFileAttributeSetTableFileAttributeSetTable CREATE TABLE FileAttributeSetTable (Id INTEGER, FilterAttributeId INTEGER )33/tableContentsFilterTableContentsFilterTable CREATE TABLE ContentsFilterTable (FilterAttributeId INTEGER, ContentsId INTEGER ){''5tableContentsTableContentsTableCREATE TABLE ContentsTable (Id INTEGER PRIMARY KEY, NamespaceId INTEGER, Data BLOB )x--#tableIndexFilterTableIndexFilterTableCREATE TABLE IndexFilterTable (FilterAttributeId INTEGER, IndexId INTEGER ) !!‚ tableIndexTableIndexTableCREATE TABLE IndexTable (Id INTEGER PRIMARY KEY, Name TEXT, Identifier TEXT, NamespaceId INTEGER, FileId INTEGER, Anchor TEXT )h##tableFilterTableFilterTableCREATE TABLE FilterTable (NameId INTEGER, FilterAttributeId INTEGER )l++tableFilterNameTableFilterNameTableCREATE TABLE FilterNameTable (Id INTEGER PRIMARY KEY, Name TEXT ){55tableFilterAttributeTableFilterAttributeTableCREATE TABLE FilterAttributeTable (Id INTEGER PRIMARY KEY, Name TEXT )h)) tableNamespaceTableNamespaceTableCREATE TABLE NamespaceTable (Id INTEGER PRIMARY KEY,Name TEXT ) ���Ü�Ü������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������"�Koctave.community.linear-algebra �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� ���A‰�Ö¼¬„lP>$ôÚ¡d% ́ ¹ ~ G × œ a * ÷ Ä T  à « t 7  ×   o @ ̀—^%́¹€Kă²Jè§r? ÑœiAƯ‰�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������RA�K� ccirculant_matrix_vector_productcirculant_005fmatrix_005fvector_005fproduct:@�7� Gcirculant_make_matrixcirculant_005fmake_005fmatrix&?�'� /circulant_invcirculant_005finv&>�'� /circulant_eigcirculant_005feig1=�+� A@kronprod/uplusg_t_0040kronprod_002fuplus3<�-� C@kronprod/uminusg_t_0040kronprod_002fuminus9;�3� I@kronprod/transposeg_t_0040kronprod_002ftranspose1:�+� A@kronprod/traceg_t_0040kronprod_002ftrace19�+� A@kronprod/timesg_t_0040kronprod_002ftimes38�-� C@kronprod/sparseg_t_0040kronprod_002fsparse?7�5� S@kronprod/size_equalg_t_0040kronprod_002fsize_005fequal/6�)� ?@kronprod/sizeg_t_0040kronprod_002fsize/5�)� ?@kronprod/rowsg_t_0040kronprod_002frows54�/� E@kronprod/rdivideg_t_0040kronprod_002frdivide/3�)� ?@kronprod/rankg_t_0040kronprod_002frank/2�)� ?@kronprod/plusg_t_0040kronprod_002fplus11�+� A@kronprod/numelg_t_0040kronprod_002fnumel30�-� C@kronprod/mtimesg_t_0040kronprod_002fmtimes3/�-� C@kronprod/mpowerg_t_0040kronprod_002fmpower7.�1� G@kronprod/mldivideg_t_0040kronprod_002fmldivide1-�+� A@kronprod/minusg_t_0040kronprod_002fminus7,�1� G@kronprod/kronprodg_t_0040kronprod_002fkronprod7+�1� G@kronprod/issquareg_t_0040kronprod_002fissquare7*�1� G@kronprod/issparseg_t_0040kronprod_002fissparse3)�-� C@kronprod/isrealg_t_0040kronprod_002fisreal7(�1� G@kronprod/ismatrixg_t_0040kronprod_002fismatrix9'�3� I@kronprod/iscomplexg_t_0040kronprod_002fiscomplex-&�'� =@kronprod/invg_t_0040kronprod_002finv/%�)� ?@kronprod/fullg_t_0040kronprod_002ffull5$�/� E@kronprod/displayg_t_0040kronprod_002fdisplay/#�)� ?@kronprod/dispg_t_0040kronprod_002fdisp-"�'� =@kronprod/detg_t_0040kronprod_002fdet;!�5� K@kronprod/ctransposeg_t_0040kronprod_002fctranspose5 �/� E@kronprod/columnsg_t_0040kronprod_002fcolumns3�-� C@blksparse/uplusg_t_0040blksparse_002fuplus5�/� E@blksparse/uminusg_t_0040blksparse_002fuminus;�5� K@blksparse/transposeg_t_0040blksparse_002ftranspose7�1� G@blksparse/subsrefg_t_0040blksparse_002fsubsref5�/� E@blksparse/sparseg_t_0040blksparse_002fsparse1�+� A@blksparse/sizeg_t_0040blksparse_002fsize1�+� A@blksparse/plusg_t_0040blksparse_002fplus5�/� E@blksparse/mtimesg_t_0040blksparse_002fmtimes9�3� I@blksparse/mrdivideg_t_0040blksparse_002fmrdivide9�3� I@blksparse/mldivideg_t_0040blksparse_002fmldivide3�-� C@blksparse/minusg_t_0040blksparse_002fminus9�3� I@blksparse/issparseg_t_0040blksparse_002fissparse5�/� E@blksparse/isrealg_t_0040blksparse_002fisreal9�3� I@blksparse/ismatrixg_t_0040blksparse_002fismatrix1�+� A@blksparse/fullg_t_0040blksparse_002ffull7�1� G@blksparse/displayg_t_0040blksparse_002fdisplay=�7� M@blksparse/ctransposeg_t_0040blksparse_002fctranspose;�5� K@blksparse/blksparseg_t_0040blksparse_002fblksparse7 �1� G@blksparse/blksizeg_t_0040blksparse_002fblksize �� !nmf_pgnmf_005fpg �� %nmf_bpasnmf_005fbpas �� thfmthfm �� smwsolvesmwsolve�� rotvrotv�� rotparamsrotparams�� ndcovltndcovlt�� lobpcglobpcg�� funmfunm�� codcod�� cartprodcartprod(�)� 1vec_projectionvec_005fprojection �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� ���!�!�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ƠP� « �������&�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l���ˆ�O�c�t�a�v�e� �l�i�n�e�a�r�-�a�l�g�e�b�r�a� �-� �l�i�n�e�a�r�-�a�l�g�e�b�r�a� �p�a�c�k�a�g�e� �f�o�r� �G�N�U� �o�c�t�a�v�e� �M�a�n�u�a�l������8�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�O�v�e�r�v�i�e�w����1� �O�v�e�r�v�i�e�w������T�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�I�n�s�t�a�l�l�i�n�g�-�a�n�d�-�l�o�a�d�i�n�g���0�2� �I�n�s�t�a�l�l�i�n�g� �a�n�d� �l�o�a�d�i�n�g������F�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�W�i�n�d�o�w�s�-�i�n�s�t�a�l�l���&�2�.�1� �W�i�n�d�o�w�s� �i�n�s�t�a�l�l������<�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�I�n�s�t�a�l�l�i�n�g����2�.�2� �I�n�s�t�a�l�l�i�n�g������6�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�L�o�a�d�i�n�g����2�.�3� �L�o�a�d�i�n�g������L�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�F�u�n�c�t�i�o�n�-�R�e�f�e�r�e�n�c�e���(�3� �F�u�n�c�t�i�o�n� �R�e�f�e�r�e�n�c�e������H�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�V�e�c�t�o�r�-�f�u�n�c�t�i�o�n�s���(�3�.�1� �V�e�c�t�o�r� �f�u�n�c�t�i�o�n�s������L�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�v�e�c�_�0�0�5�f�p�r�o�j�e�c�t�i�o�n���(�3�.�1�.�1� �v�e�c�_�p�r�o�j�e�c�t�i�o�n������H�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�M�a�t�r�i�x�-�f�u�n�c�t�i�o�n�s���(�3�.�2� �M�a�t�r�i�x� �f�u�n�c�t�i�o�n�s������8�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�c�a�r�t�p�r�o�d����3�.�2�.�1� �c�a�r�t�p�r�o�d������.�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�c�o�d����3�.�2�.�2� �c�o�d������0�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�f�u�n�m����3�.�2�.�3� �f�u�n�m������4�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�l�o�b�p�c�g����3�.�2�.�4� �l�o�b�p�c�g������6�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�n�d�c�o�v�l�t����3�.�2�.�5� �n�d�c�o�v�l�t������:�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�r�o�t�p�a�r�a�m�s����3�.�2�.�6� �r�o�t�p�a�r�a�m�s������0�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�r�o�t�v����3�.�2�.�7� �r�o�t�v������8�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�s�m�w�s�o�l�v�e����3�.�2�.�8� �s�m�w�s�o�l�v�e������0�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�t�h�f�m����3�.�2�.�9� �t�h�f�m������P�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�M�a�t�r�i�x�-�f�a�c�t�o�r�i�z�a�t�i�o�n���0�3�.�3� �M�a�t�r�i�x� �f�a�c�t�o�r�i�z�a�t�i�o�n������@�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�n�m�f�_�0�0�5�f�b�p�a�s����3�.�3�.�1� �n�m�f�_�b�p�a�s������<�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�n�m�f�_�0�0�5�f�p�g����3�.�3�.�2� �n�m�f�_�p�g������R�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�B�l�o�c�k�-�s�p�a�r�s�e�-�m�a�t�r�i�c�e�s���2�3�.�4� �B�l�o�c�k� �s�p�a�r�s�e� �m�a�t�r�i�c�e�s������b�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�b�l�k�s�p�a�r�s�e�_�0�0�2�f�b�l�k�s�i�z�e���0�3�.�4�.�1� �@�b�l�k�s�p�a�r�s�e�/�b�l�k�s�i�z�e������f�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�b�l�k�s�p�a�r�s�e�_�0�0�2�f�b�l�k�s�p�a�r�s�e��� �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� ��� �û1 �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������‚%�„N��ßxœ½‘MnÂ0…÷>Å“P7($Aü6,«r'ÄVÛrL ­à,=KOV™HP•J́X̀ffô¾7󜧔z̃:M RI\OÖỤ́0©¸ Ểă“Ù%ï(ÏqBiÅú�e U#:«¹W$$µ„qÆ€Êjë Œ–‹U¹mPZ/ÈO₫ pd̀]ÍüæÍpú₫*yơÖx»3b¼ƒ½®_@µ¨—tvà¸Ê4̣tAíx©)­¸vWÉ?-0u}„(Ñó|=_ WܶÛ×ÙË2÷JY`çOv¼"ÁMÕg^|Ï]+j³l C{̣1 ej‹† yƒCºø¡̃ÿ{í#¢œ8Oµơ-ăsư'́;ñ7�âp�@�xœí}iwÛF–èwüÛó"̉)‘²lG–tFv6cÇc;Ûx<9E HV à*€Kº§ÿÏûï—½skÁB�$H‘j÷›—>ˆ@¡–[w«»Ơå_¾₫ñùûß̃|Ó$ ®KóŸ¿ôzđ\P’PFKøîơOđ.X4æđ¸?ta$±¼89™ÏçưI”ö¹˜œH>NæDĐ“D·<^{¤Ä¿v.CơY~JÙ́êè9%½÷˘§]%t‘œà,‚7%B̉ä*Mƽ'G×ÎeÂ’€^ÿè%dF!`%¢G‚  ½Ơ1ñnɄ˜ 5®>»<Ñ8fF éƠ‘O¥'Xœ0¦r§®K#Ü̉åœ _¨{A%O…G{I>÷̉FÉJsŸÉD°Qº²àIÀG$Xiû¨ …†!¹¥¸Å+MgŒÎc.’BË9ó“é•Og̀£=ơĂeK z̉#½á^,º…© ă«£yÏă#4¸:’ ÁÎÔ]áóërÓgTà ¦}Dyó́Ưµs)“e@ac̀“̣H£¹ă³YŸ.H₫1aQ/ ăäÎúC₫·#Á£Iß§ă.₫:æQ̉“Ë yÄeL<úÔó9e“ir#øæ‘d̉ ˆ˜PñßNôC"n{£4h ˜Lzj‚jó.Àg̉ûoGÑΉznm`² ¨œR+-/È@¥Œ?}½Tǹ<Ñ”è\¸¿„€D“«#©w….}6/ R^%<îtFƒ]àvó³}˜ ÍôÑ==ßOO‡¾™DÏ ñQñ×—'ÓÁµs_?çñR áÿüox?¥`>{#øÔKàkœ©à\Äê›7T„LJÆ#`&‚Dȼˆ¬@"2¬§0£bD‚ÇcF%đ1$S&!$QJˆŸ1?ŸRlb&ñ„yÔÁ¾Të8R¿"(Ä‚J*fÔ 3F¿ÅTq¨Ơ©†ÜgcF}œ3~R™lùT˜™F>KT›1Nq‘KMÜâºH¢>¡QÂAe$,€OĂ¹Ï¹¸ÅÙå3ñ #%T„j"Ä©ùØ«G\’)è®ËO‰d@’º•³(á@"L©P’ uói:dÄg«`©ÔLír*®KèïMIœPQCẼ2®´/7é ®`]L‡×Î%±Ÿ°È§‹±́1_©ŸåC\¤Úø ¡A8 ¿%,’@|½T˜¦`›ÓÈS@è«Ơ�8zÉ'>›µ]ù‹H&$X4é‘Èïœø,¬Cư•!äïÔ®›wíaÔ4™6 S™ÀˆÓ}P4YÓHÍC#äˆB*©ßÏP÷E‰Êß±.Éh$́|‰'x´ ®¿{ưÓå ¾¹¶üËg‚zI°„±à¡‘ä½1ê! › ©Ú¯Mø…E>ŸË™ƒ‚₫ÙÊgG×Ă₫�LK;ÛË“éY;ĐV†P0EŒA¤Q„{Æ"Û¿«˜BZ²Jüe R®¢ñ)ơn±‹‹êÆơÄ‚®<íÅ‚¹I’Pÿè:¾�ΕưÅN½68]‡ÛÍ`ÍÑ©¢Eœm̀bÇ¿°d $BFED$áHdFX@FƠpm¢y…ˆNˆ ©̀[Ùר…9¤· »ó àsüåñ0DŒŸ³dÊ"§%ïaÓ̀|7́›¡]’P™ âC‰̀9¶–9ÂÍY ¦ù|âÅ¥eÉé÷Gs&© ¬Üǘ¦D0—FÅY•ôu€mÏỖ°?́?́'Dô'̃…2~(°ù:²8ƒ2̃Ư’&~(1ëËøú-áTJ»½!M¦ÜÇ_,…=sÆ\(aÏ‘QKd.ç\§Ä” ¿7»™ïœb$œøvăöÁ—°»6øƯ09%̃´µX‘TiSÍ‹B}Ù₫­\ï-SA#®‘ëƠÆ(ÓÏÀ>‡́y{y^7#ËWu³f\ư™z ½ ê‘¶¶©ZA�úyIí±º:¸FïầÓQóägÔûưôô|ëƒ"/çrú°ú±i�øẼụ́dú°ƯLëF2s ́×c&d̉óéăđ< ¸w‹“̣Û¬Ü�ñ~ư@æK“(C,’Đ Kêè:Ă oY@/ạ̀›^_zܧ…µ¥ăúrF2 ™qtÍÓạ̈dFÄ5\]à7×p©OđÅñ t½ ;Ưî*cáïeK‘G×ʰ =¨ •7Kư¦kfsyâ'=ÿZsĂXr¦x$UH—ÏG¯à¬g^đÂa§ï4M�.�Í 0€œ))Ø4¡rËJ«„Ơvƒ»ñFPÿ”¡÷Ô=ưè‡Ó₫¹«₫ÿ±ëè¶_ˆ!ÂiÿñéăA•‡₫\³FĐ(6Ă…GLĐ ä̉u@Đ$‘•3¤tí$@Lk¤9L%•àógï§^â:đMề§Ỏ"tƠö‘hPÑdúˆ™˜>,ç¸ 4†@@£ ®çPÅ;}Ø=A <ñƒ̣¢™Y½"‰`‹Vœvµ©æ´CĐÏwá´ƠÁ·ă´ B~Å”m׳æ=„ŸÚîwă¢M¬0_æ˜àŒe?mâxNỊ̂¤6X‘PÉHd‰�ikÂf4i˜#|Ÿg¿º}G™ k¤UsRÔK¤ÄÚó{”†#*d~¸ đÀE6£Á²Ày¥UïeL=m -*\sñ7j˜zj….ßsđHà¥x\i^WÎT̃ÀÜÀÁĂ¾†~¿}x‹®A%ܸđ̀…ç.|*ƒÂ,.X2 цÆ4Ñë©™ ç 8> üŸ·«Fñß@¯¿–¹NOă£ëVü̃âUgp1tÏ.º§ÅÜI$á ��p�§†ă«†u±åĂº–•‡¶ÏA]Ÿ����� �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� ���t�ù t������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������* 11linear-algebra.csslinear-algebra.cssW 3linear-algebra.htmlOctave linear-algebra - linear-algebra package for GNU octave ���÷�÷���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� doc ���î�î������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������!qchVersion1.0���ƒº>+-ơĂ¢ÀÉ9¤eœ¸ơ+¥]¿£¸C’_äôt+¬†^ÇdײªM\j̃V êp¼iW¶T¯Ü}¨p˜Oj–h|ó§~ó±…BèƯ‘’zÎW…̃BÏ ữf€?S€Ö¼‰ÿÉA}¶GP1¥AÀâ§÷ O×4ŒÔåÈ« \$S>QΟâS.™ÖÉŸÿøu73Ăh­iPm/¹Ă‘ ©c¸ª¾2èú  [«/ ²——ñơ4iz„CxƠ-{¯3ñ¯|øUqƒđï£ë—p!‹:¯\xm7@ ê¨q(¸Ơ¯ ÑLnØüµP¡¹SÆ+C¼™zSíö«™~Ó÷ wpñ̉.{Kă˜ ½r1ư“3Ÿz[ơụ̀ËÁÅëb¯RÁ­^“;°Ø đ4‰Ó,Id›Ô ŒÙŒ+_¦œ̣4đ­Xäh[-: ¡óïo˨ßíĂ‹H;="[æ�È]EÔø^°₫Ú$E—h?>†/„ü”̣§§æ¿Ê1‹z8b=`s.U ƒc‚z(ûSùd±¡>#SßÉ ­ÁÇ—ˆ/såù’†ĂxztưúÇ÷ß\Đđú̃ă>àV¤BĐg ÁŒ“Öê¹ÏÓQ@áßß®̀*R ’‡Q•y·Kt³85dMËL¢ÇU|:3!(ˆ4¦áÅÛÿxÿßjŸÊ7on§ÜZéû$ªÇí-µ¿q…ëƠ¿3<?‡íơ?ƯăA@́ú æ½g­{&wª7jη-LzFjª`7*gk ßÚófîWaTÀ…S|6%‘è�–›̀Q@@~Jñ´«‡ÉQó[.ă'H°Q_}8]ÆTŒxÀ¼‚{¤i'ÓqXàË$MxHT,G°t€E3~‹Î5Ăh™„‘̣Ëñ¨®3ºˆ³ÎtTQB«À:ÈŒc<Jßœ¸äÈfX÷™‚ ó)ó¦X¾ï@ϧ1Đ­„3Ê c‰ ña&}ǼwO}¨b¤c7iFÅXD</xʯp-ô£rJÑæD™ ë«•Q"—f9́Oố"@‰ú[ÍÈ3Ú™Ù K˜97ej™T°;|ă_suâ' ,yj%²7ô‹©0öŰwùI$æO×> øÄ2ÿ¼!]Äæ¯§Ê G‰ï¨±‡Đ…€OBµ·¸×/¨ÔaP!Ǹ">Je’Ị̈-'ål�đ ®ô²:7.HuŸâ¾³–ü$‹:]è®Ú‘wŸDF¤£Û\ÁˆJIƒÛtÖ€]zѸ°Đ¥‘o?vVWc»i³$Ư6ŸÈËAG¦4ˆ ô¤ä¥è`œRAµ 9Ñ%ĐE"ˆ₫È2D…-vÚ50+"0Ơ´(8†áBúa‘ƒIíM/ o弄AĐ?uQ{0ŸZœ4Ô=¢^ ¡|ùȘ,æé`đ¥ÁÁíÄ7²CWá¶FuWăưezÀG±7Y/Ơ‚nƠ^®Û^"Ùu燵î¨IiŸÎ¯Â7 áÈ'í wĐZÍ  †Iß́Û0a P3ĐÖ¯y=&,Hư6 “ÿy»³OËÑứNcß3™p±ll%¨d~J‚×\„²Ôø3̃đ5-mlñ¾±Ea*¿mØ{PATDLCË,^hẈ…6´Â¸n4W,@Á²æ,̣3*á{Œ·N”7L½�Ê&44´̃XĐ,PE“‚w+3™ ̣cŒ/ZW%B¥SĐ™y C¾2Ñc(‡¹\¬Zö¸TÆ\«ïF×ácmëBw8¨oº5»¨a¬˜N q¨äÊŒº`÷y#PÏU?{ÍĐ‹ˆ¡*ñ&)•̉{bX¼«́s¥ÎH²€`xÛ]æQ  $�¹ ÍÑ0[w¶LxœÈ>“r\Áà©} >UĐÖ©"B:Å•º0DÅóCù™̃çp…û&¡“ äÂKß½=vƠ�Ư§cæ˜ïSƯôö;x÷i}\1)|×Ö-t+mYL0. Æ™ôáEM$H…Ñ¢Rzª"Ë•¢̉. Äa»ơŸê0†§jĂ”Ê1/Ëô˜L™0óó¬i7Ê[!¼"yµBmă$˜¨,±‰î7‹+=$<[à©-Ú=©™é*íƠºW˜¸:yê�R "˜Ó Đư"ÉQ±™ó÷•iºÅ\ŸXÚ¦N )™Ơ»jWІì cd ÔX̃—#€Tv™L|„¬SªˆE‰‡²%86ÑJ×J­îGˆCh~AK¬½†’ú̃çTWÑ^̀j́%$Zª•XV_²ß¶ûz gR=™¦̉ÚŸô]Œá¶ÙYZ€) À’¥M₫�™ˆÔKRQ^Íoƒ’³qKÅ ¾ÛƯ@¥ưyV¦ơiH&́¡ÆâƯJ•€+8uaࢄÚ!Œ¼yªí±ÀÄm‚c̃o¥J*{ŸƯî¹J‚<tŰk=Ó*蛵NÈ́ Íbǧº₫öP}Pol'2Ûrăk™n|™ivtf QÚ26uju3kxcG½Ç½ ‚y]èe*�‰cÁ,ÔvÍ„—ø®ë@YC±@‹Đu¢ÆyÇ₫¤5P¯™ƒe2ªGA¢[ÄGœƯVñ»¼�Wed+¼°œơwmÆ¥iW1ËYºc÷¢(ÜÜê¹UËöoƠ¿îÖ̀ô$5Á6?ÆÆ3˜›´îºk«Œ{ÛMÁvă:h‹’<˜©¤¶F±Ø ĂSåê¢c’ öOĂ8YÖÚï³åÀ¼ÈüĐ›7ü}yù¸ê5‹^ŸÈ₫íôÖLê}Igë¢]´„¯¥ÙV7Ưă‘LahÜ'µ₫ÖH­d•¢úù[~Bq3è6_ÉSˆÖÓéot̉Ô±üe¢µÆT æ§-œ¸™fû¬×-uè@ëâU§ KØSëµB¶:µæÁ ~"̀q(&‚„4¡B̃e_Dbus2™ç¨£–(*}ÂDđ@Ùr¡CciÏk¥NúöÊ’¶°U§TêNÇ@'raxÚb.µB»”)÷Ù)t"®Är7—â%oc¦TÙ}Z$ÙÚ –Ç@• ‰>3 ª {¡µZKé ³Y¿Q}2‘YĐ-¥Ö¬=õtÖ´{¤¬H¥£}+¹̀_P%ªæ*Ư²ƠC©jq*ºx.̉UPFèàżùur£N½[Ưˆíz\£ßµï8Ư·™y<º)Ë#³©ëåjí'Zcm-ǿWåË4Æ’)­pfDµVaU†ˆ'ü½rxÁáªזרó˜*É }̀#‰3»w´ú®º_×åûƠĂÑ+TC¢̉.4KQà x¯\j�̀¤R…rù×½²|ª»z$p@bt…"h̉F]Vέû0ÂÓëCg”tơ),™óRøF±{́ù́A®ăç•t-c̃C‡jÀç.̀Ul›úöÄ+ÎĐ²�ĂÓÅđÔ è胗ή•S›Ù¥ƒ)ŒJªuVă£}uó₫‡›g(ÎLÖÿĂ=oà |ÈOЉ̉p"˜ăwÇ. ]4áEϽqaPgŸÓË2óBpïhyÇ©}ø»ûw÷Í…AÉ·ÁW. ¾úØnn¹O¼Y³^‹6¹̉o1 ¦̃8JÅ!¬Ÿ{Å&Ÿ¥œ›¨»®¿ÎzêBAt(Ø(ÿ t‰|­³<麘°2 ½sÎOµ-¶%Œ“RêÚăW(جâ£4±FÑ’‘ËHŒ*àüÔÚ;0 ŸúƠ  <,µ'¸‰®àĂǧ̃ïH±æ j  ưâ!FZ4ª«đjø‡±Đpc¤Iqù?W¥¡~+ơóëGơea²P₫2slZ<VßÄ$•ô©ƒq,M{]ÉRT¼óIqóF*])ËëW4óR Ơíjhœ/ùùƆ…©*CêT:c<•X^…c  ²³è°Äó6ó¦<ĐQIÊ–Ø9Ơ£cyt¬¸b7ùükgÑ}ûŸ·Çÿ¹hô`´§Á]Ơ£é¿³èZLyÔD—^13@íPaXª ƒ*‹3</–brEú:u5J‚œÇƠpE3ƠLùRfn%{ĐÓ®],›¾Rq?öCíkÓ́³h(B^ËlI••èÊ:å­ G˳Œ̀ƒ°TW±ë€äRç*œsắûđ¶(Zw÷ñƯydL—:Q· ‡y»N2D”ñW’HÎ)±k3™y4A|N…Û&u” QûĐG“PoéxÓ5æ3­Å<»z¡;f&¦­‰Æm}?dÂB.qÛlt)₫ÉC•IP´·̃à9ÔÖ$ŸU]DŨ“Ú¾"§ˆĐ壴CD>&l2K©aQ6>>¼¹ë̃{®ơ…e3!˜A TË–§§§Ox•=1N@¢s}<vÑè¹UùÓ«ÿ\<uà&ụ̂| 2FüA/1bP_Å*₫Ê"¦[ä¸u/B²ÀÎâü©ƒ–;)ÚĂJóÂÿ‰(.¢(v¨P3ák{ѪWᛪ«Ê7u¼°¦™â€'ĐºCwĐuẢ|²„8î>…)0¾[æ/¢¹ùÅ“ä)úuÉIè¿æ«„Ç]́ˆ,˜„ëâ6tî°‹óÖ‚₫¼̉ù €ÉüTä^û¸d-¸vYú°í̉%.½×“+ ̣°‚ ôÙcNk ĐY|98}€1»‹n!ñÈÔ´[¡’`o 9ëºĐ&J¸÷úVaR?]è`aÓpdFF:¯ gưs4TÎŒÔÙD9ö‡Û@ă„_Z₫;`8ëŒV—ï3̣ȯ@`E°äµ$°r)‹RqwYq ytÿm*G çW"Y´Ví°ah…“Øjq±¢ƒaÑé„$ÔÁ•¾J2ª:7Y.₫yĐ-§X7}ø¹/£%ù“Î\xÏçDhW3÷B8đ¦<̉7(è”PüÀµ04­áÊøƠOÛÉÁwvn¯ÔÜ\̃½¸yÿÆS¡DMïT3td9nÉđ :ĂÓSäïĂĐ…8îĂùàqïü!œ²èăTб-4‹Ơœ/NNüEßçL•€œöƒ³Ç'ï§>>>?=={ôh0|xt½Ec¿¬KYƠ£Àˈϣ̃(H¬2;S¢́ÚG×êà‹ûĐ F³)¦º-<,¦¥*)¨€eŒ¢RW(µ₫¬p¨ó4T ²qB#ü奶©(ô X²,„E˜Œ³¹` ~’pSŸAe›̉XêPq“Ưá-ÿ?Iå³ C¤‘,P³ÎƦ¨`#/bôÜ=Q:4kÓ¸vW&Ê®hÀ R™›("œ´ÍÆ$¼È R³p¼qw%3/¢Mˆ‘ ª"0èơ ���/¾̉&—¶Çä„]·â5 ½Á© ON7‡Ơu5Ü_Wgëº*§gmØ ˜ÿu±r÷uñWf f₫$K0̣x!‡$™öSÏÇ#³èS?=ù;¹ƠŒë$#àu „_ßÀó^‰¥b§!¢"Q-§];)ü¤?á|Đ¾ÇĂ“ød„•ŸùŒ[¨éd9"&ă3+ÁZ(²i‚ƒ"xóÍûw:cîûß̃¼ưæÎy‘ïñY¬Oô8Ó¬}¦GÖïAR=LïÍă´¾ÍăpR-4¿ÚW¶”Ăú̉ X¶«ç³9°q¿Ïˆ`x¬4z ªe­ƒ¨Ç¦9$(ë…kƒ¼‘6nÙđ8•DèM!@‹•œ½›ªDucĂr?íH9B’xScr+E*Ü]Wà̀Í"ạ̊‘VöÑơ²ˆJg»³̉h*O²hŒ»Kf¶Ó7¯bØ…«« fƠ†vóU_CgËrg ëzª 56µ«ZUP0vØÀ6¬âåª dª8Æ;³ Œ?.ü1t±|U4S—ñƒú6CÛfˆa›~¿_ă÷™Qeà�;¨]½Ætªe´¡ R«ÊÚ.•đ½×qÈXóªëV»h~eÑ?®.₫ĂGˆ‰”v_ëy³̃SN_×áO–RG›9G1ˆ²»¼<Qa@r½Ä{YĂö2¯Đ÷A¤^Öÿasg2!̃-ơÅ)5h“RU�æd¤([+ễÛs´óÙ‘¡#ºEßQ^ "Ju <™u°dü$•´2öÜP…6ÚNkæh&Êîk+Ú8 ‡˜w›Â~utI;gƯ‚}¬ËÀ`ˆñ‡™K>^å#‰.¸€ê¼˜AGFí‚́'}\́³¼·SƯw¥*uvæƯ«+bÄ,ksÑû₫̣€¯m4¼.~ϲr+¢Pn…à"ô\˜ù$âX0‹PSÄ¢9Zèp¡Ÿ¼&¯e:6cåÔ†'…Ư]’Ÿ¦wÖ€±“ờà±h+>0; ˜Të­µ^ “öä 3Ồ&°‘n±ă¼Z%¢Ư«,×.C@2B|•w™éÏOLYÚ¿Í₫æ€Đ4;ë̀àƒK¢ÉÇn!º^c¢ªkQÆnƠ Ú₫f…:·ê†,‚"\‘Ö¬« ¢ Ư°I“‡Zi`sCNæđ%x\vjÍzù[ E»²zí .eH’Î<Ÿ· $ É°{uW\Á́„äcḮÔ 6S- ;… ta¡gz.Î\“¦–�3P‹ø Ô¸hö6¿†øëăd¬™œ«¶@ưûî’^†se¢\OÛOÀ¶kOßyÏ¡qÛưAé|ÑÎsǿ£ü_åMÚœDܜӼïù ä;•08(ä´™ư>ÀWLÈV~a�(—2¡aƯé¯s_ÂO~>î>øù³,DÂ.7L¶!Ñ+Ï•rVôIgèd·‡a·ÇñnJEH¢̃+.“<êư¹?JÅR¥¦qóoÄ®EuÚXY‘HÀÛơzx’{ —¤i*_~ß~s€ªÚ~:ÀŸ‘(!ÊS©âA›†`yå(×xô],…„*±ÅJZeMI}Û_VZŨ´˜ Đq$ºbUOÜQºˆ©—d÷GaÛ¾£® ¢Ä×5ư7TÔÄ\ Tª~ñ"¥b¹js[!n°:í"N›‚ˆ:aD#B|6cÚ2›Èà;kzX+g½4ø ty±¶’@÷x)€]&öM “ƒ7CîÓuǹb¸“ºqªhV±Đ\£AcM–k>‹,ÉIÙU­»q•ûđ3 ˜_¶%ËX´Z±̀ẳ>ŕ³„TIêU¾”ƠGÜVDÓ:NÔgl¬²Ê¯w‚©‰9œŒyW*¬í«ZæƠƠÊK ªóAgá±Çåq!&-ÓæÍ.y\²(•Ơ¬kFf6Ö™×*oËÙ´³ÈN+ưD<Ñ}Jô‚BüUå‹!¦9 1<â&‰ưÂÑ|>/e¯̉Æ›Ă*t”*¹6&â ­\e£X^¨µÅë­ĂÊß^ÆươE k3E°L؆´UC¬ Í1ö1ưV9¯µØĐ…ó´,J&ø&âèb(‚ÜÁ!ŸuÀ…ùƯƯD¬Û#Ti¶½ßR̀úoqH±¹¾Cä,»C¤ønû{DÊÙî.‘(«+F1YkùÄ»¥°-¶ÛÂÙWêư0¿Â‡5₫̉(¬¾o|ƒáIÍŸ½x×̃Rÿ uao×Û×x½ăDW:0ûm©dñh ÙƠ$Ṇ̃öÈÛÛcêĂ”È̃)±,mÔµ b‘ÇbÀSûäFÇ`½£6\©(jX^#E«̃:/¬|¡¡­ua|”M�©?xÜZhYƯë_Ö}kP¢`é­x²²»H®;ƒ.¦Ñ2Û38ÂøÛß«¼6ͤqûÛïß₫×0^gX®sˆáK A<% Ëùeµñ¯c¯o»̉qnîêœ}ÖkéÈ4ü½Ă®ƯÿÖ-¬sá².~=ÀƠ™ơå¥ÏÍfTŒå½:]‹‡¦‰ñØb™&S³^'ÀçµSIƯ8–J.à…jî“$; vBX@Ô]KApï±ÈOŸ÷lÂđz1e«!s¶g¼¡™QeˆµÀ¸₫"PÚĂ¥$aœơGÂøèúư2Fk ăk£b”8Ü×¶@…̀ÜT¸1|?SˆMƯfôÍb\Uy:è§ø”2ï¶”’w¿"J#•„bƠku ¯–*’°ºÀ†ú誷*—$+ø“Ă-ÔE₫Å~¯ƠmŸÍj#¹¥MüVJg̀uh¿ùúÆö¢´7c)Ñ÷jœuUØF„Ee½)‰&´2tá|đ}ñá ßƠAѿӇê¼óÀ.PđÅ\x½iƒ‹p×±©-Ơ¤£útU •X1NæÄfU4¡Kú%¬07³– 0èæzd±“*¾ĺjØĐU K6örVêÅ\î”wÙH¯_ÿđî1·lA£¸J,²Ù.0&ƒÙêYGu+LÊ·„Eđađ±XDnƠÍđănĐºÃ¿Pol#% ¶¯́7’¼¢£\ƠÑ9Ñ&L”¶wÂé́×&œû*[~lŒ&b4£ºRá®Ú…UÔC K‡9Z1ËI){Ÿí¯³qáÏh̉nƯJà­_¶óO´îWºÊÉ¥¿" ¦am•̉NO·—E›ÆEm§Í¸Ăm†%‹÷,\'"író:j˜ë[¥ëHUÖ́n³î_Đ’½fx¥fÜv³j%ú:SĆ_Ụ́ư¦Anµ.Säûöƒ¼ÇÛg‡x—đ8V> ‘_†í)a¸l±ØˆO¢3³{$T|4&zo™‡÷?₫`®7^Ưüúû‹÷ß¼’äY²¸qí×ó³*§³5^d¾ír©*ú$§|®Jú؈/?Ỷ´±₫)Ô­àÍÊ¡.ä{G¥đ—5kúQÁc‰d²¤́̃Väv3µÁăÙ>ù@[ÄÖóŒ×5¼¢ư"ĐLÑvó Å u¦F媥ú₫I¢ (ß±±{̀£5–`.ûàa‹O†§î±.EWß̃¹ÇQHí“:v‰¬´>/6F»Ñ±{¬Ơ·JÓG§5m•êý+îẃbîE#vqÚ]÷Ñiwµ—Çu½˜W¦;qΨ»ƒ₫À=F Ơ„óæÉh ¶¥S­7µ P»³x˜”q9Â21êŸcÑ$…—Lß©̣=¡2à ·YâØ·J7„MÖ¤ ¸×tyfvø\å&£#Wº…Q_DđFpR ÍJÑ OOŸ`.Ú4™Â‹o¾ù^DÆ:¥N”ÏydV‹Ie_ăa…*†é¼x₫ơ+{Ÿæ–ŸŸơÎ U¹'fÜĂ–C£’i#́×À7O®VUTèHJuơ›n#¿_¦‘ä¼’-qÏÔF…îx´‹iN_Ù”›ßLF^±ăƠÜ<3›ˆK䘪‡üD,5]8;uáñà¬÷ǿ43â<W±…\° ÓÉè&NJÉ5ÁJnÍ|>ï{^½©Îåù10K­ij'úlçC@*Œ'wO«1æêxí*x¿¸p{[{|¨kṬ₫Ávö¶æ̣ønw5üÜ8£¬6ÍríÛ„ÍïXH®ùÚd<7ëu!§¨—1‰º Ơênđ<4C9æ²ÅdÙB ₫‡ ±ùĂ+%iü°?ç~X;e¤Á£Ùœc$‹ eÉÂPÖYÙ«ñ"+{[óg¸‚_|!IYÙ’_ê ª?Ơ”{.Ơ^Öƒ˜¨ h\dA9ªëhíå³ d¡<* Gø´Py¸p^7Ï‘©d ¸pk6E2(ܓٌ‡tJgé:hï+[œn¥PÉêễ¶ˆ}JuÚ¢¾ÖNÚKí4²Z“Öi7¿º¿m\,}ø§jK0ÍDk+z˜¬"{fÁă¬À§ñr2n?oĂ$#á¬:Á¨ßÙ‰YÏÊZø~¯—»¼’Igpêë"[~ï1ÑWsÆÎ›đà Ï›úơOæ+¤”̃zä3wB²è‘́üÔíVëḉÁ›®¼=­Âö,&¬q§×¶×₫ô‡Æ•X¬„“—Wh!Bæ²G}̣{̣ûééĂÓQp«{Ry₫ø‹ư¹6æøa�ÿ}ub¾h¯�dCDúă*,đß_íOøgkÜ Í#Ǻ™„/J‹Áû#è,Ư ~gU®y£Ơ¯ơ[=\Ưjơ×v›m†9Èvgư4ÔĐ–£̃¬Ï@t•5*V4¾‘³}•ç°ƯăÅxÿÔ°­ÓtßD‡Û=^…wßûaS·Œ¥UÇoeH= „U$èBg뇔( új2¥IóIÀ'×®«¶80JYôXmí"». k)V.e' 7°oÄ,µÀ"ß”#6¥7%¢|?É#/>Ưp›ŒÅD­úŸ•!¨«âLñEUô5™s§±°Zf.rú`ă‚e3’×O)*Åđ;ª¼.3{‰5ú̉S;V>™§˜_ñÄ5¢N{mL1œº"¡ë(đ&äăou.€F ]F(óÜg'©™àÎÚlƠ>`€ö ̣"̃Ä2ªŸ|2…ªET_÷µ÷̣q–{ßP™!g‰UÀ¡iÊmz6n0äÛpOƠË6©0w[pÏkÛîÅw_6¯7hF×Ú>í»—5}~²}vë*"Xhv.Ü ÷¶ ¯ô]bTË l)Mô»a+}—»Ÿ¥ÜÈ4 ±•ª€ ±̃„ñ)åÉS}¼Ö«´S[]Ú Ơ¤-PâW˜:~ m×ËâyÖ«»gEu7ÿ¨½¾[èĐç›}ª¼Åµđ“•ø+XƠÊó ±ơ{Ç4#d¹AÄ|Ñ;²!{ÔØ³Uî/¾Öư–N¿%}î0یقë÷ø¼¸Çؼưëξ»{����Ôÿơúö¼µÏuÙ@Ø*s6²ÁLêaÖọ£â&ÛOÚot>Èá6[îÙ•¯rëí–í8<*úÜó[›É;B‡LÑOÑ=Ø®ăơÉë÷üqyÏñƒmv\pèữ§T·k<ä~ëê¦æråX‰zºé¡88“m,—OÊ›½­á2äà¾GY¯ó[.™º·@çy£ÿ̉·̣©ÈÄ=d¼×#@ˆ™·ëwÿ«âî«öí·̃tÀ}à¼ưm»Yàö{nKsnaÁ«v2̀0§¦G:Jñ”-ª"ä¡đ#Àâ ₫&/Öi G̀7[ I6Êơ½}"J¶Ê]5¾;¡Êr ¦¼±4ÈJư }uư AƯ]³&«¾ö3uI¹­“`®ô´ßIä…L¬°¶ôDñFÙÍ“É Î«eNû/–›t0¢ ´ÖK“6¥NN¶× `‡5¥„¢q•|Äö›-ˆKÜqíSßÊ×ùÿ0y-N^‹öäµÜ…¼Ÿ3y©«Ù6WÉ+¯¿Ø‚´̀'¬=êµvŸY«:£M¶C^ê bK¦–r±y^1¬¶ÏüÚØRÇ WºUR©½q‰Ä\ [v›Ä‘8m₫föB=ậ@8›ÔơAÉđíÛă³îưàÚú>å„^àg¨®ßø₫½jê-bÍJ÷í"Íî'̀¬÷pˆqđ(³{‹/kc¢”,íÛZhoŸ1û{¾ÇưƯƠ:sW{{Çê1]óîPÛ$̃0³~ßKÆwóÉoÇ8°ençîl»åîÆ̣Ó‘\Ăô_àºó@₫±à!TøB˜–ùAÉv¿ƒc₫>ựö‡8÷ă–ÿüœñi ï dâO·´̣¦7ólx¼?lHw5ô¶G…<YèsÁ„§‡’µ?Ưîøúü`ĐàÉÑ`ÇóC{,H#"–€Ắ‚đÍØÔÉ –Å3–HŒ³(ZÉ&º(^³QsÂØ5Uç¥àơn©è½QW?&ẹ̈tªu’Î9doÀ¾iŸ¡S7…ỬsnÇ+¹}Ʀ뇯£†s̀α˜¶ˆ_³#^¾Ùs\C¶È­ âå›±r›½Đ̀ÔʱDß3ZnG)”îmÎo%^Că~ăI®ø;JCº¿2ÚµR̉Î1Y(Ǽ;O*cË¡1đ³‰ŸÜ€†º^µ¨h ¬àaVáè§”ÍH@£Ä±×´í/tÚνæFµöXC¯ˆÑÙĂĂ`µO×̃zÁÀÙ\|ºÅƯ¡ªçĂ£ï>c<qyûÆ[sm§b“6ơ„è\uøZ¼E¬q([’­ÊvíM· 9½Ñ²ZSƠ¦®4i47Yf‰¹‘³1(¿®÷Ozfó2gSJ,¿CÚ"ï˜âáÓ¤&ì¯û_ŸàAC“g¶IT%đM…̃‰^½̣À3÷µ”WïdËǘ"\‹M[*øŔÆD¦±mRèj©ëÓd…y%΄¥a‹¿÷ÍZfRLÆë¹ÔĂ"—b2̃.ư>øÔ£•ơ÷ͨ̃aí7“`/ÑƯV·ƒ÷ÈŒ3(&±‹Nµw¥Đ­_ „GïKF:’ÎàtÆ'q(ó½TWû¬Ë³³tU%¨|Ǵ:°Ö@ÏZ›ê›—t ´:׌TFÖ<¯ànʱéë₫hrC¢È9&TWºeÈưhÁ{t_í*̣ÿ)´…bw;éÎu?ä´)!çs5JóØ.ç~¨hNÂSrÚ3 ” ¦,fl²³Ucg½Ô”Z§¶‡eÅZ]&UMI]§‹R \ç눙¦9m5RØđ°G‹¼xA*Ưâ0Ÿ^ <f˜*›—4iÈÅ̉ƠÙĐFå`Û4đ1hN±:êăU†^?¨«˜•oÚâf¢ Ä ö́C.ñ­½ÎøÓx²‰°h‹{Uχg{tÿ©å˜›×₫1d‚tơØtD­µ'h§´UÏyDóó#Ù`3È¡På"mÆo ³ÜQlq8vµ–̉¸¼Âe¢?}'©P²–Ɔ¹¸Ÿ‰Û~²MÚV6Êá }ƯÂRD,H3[5Ûü•"N^ -3ëtñö‚íp0[¿[ÚL_<:nÎ>Ç4²ÂlvM¾ tæ;d ß®+('ÇÔ\° j’`g5Ôáœ}9®àЦœăs•e¶‚ĐÛæßú́5Ñ|Ç´ă'S5ÿñkÖ§}U*â°`•o¡™ÊÅ„·alºó©v(¤Üz{®̣³ 3Ú5;úü´§ŸE†ô^°Ó$gë ïJàä×w³óVăÓ́L–1Q}²&Aî÷ZÁ®ôŸ†K’̣EåwD<¬:x´³?6 ]Ñ»oÿhvù ‡C»›=¡ç«Üǻ…¼w‰B–aíê¡€´ÏPÏL5i«oêh3@²Ú¨56Á¿₫úëü"X¢œ1færOME™3₫³Ñ>³r請rq± ́”¹™ú€ Äk€à™®Å^ès*hå6×–½¾Åá¼1©Œt̃dÙÂb*B{£“©:df±gV³1Hư\å¯e|f—B$‡U±ÈgR‰„́rÈú(Ø<}6¶×*h2§xưl Í(¯B¤oèmô:¢.ÖÉô™³&6wñvX…íú¦!”¢R_B æˆ^x]ÄXwF@¢$yíœíÄ«‚~ñ¬܇‘²mj¬œ« ¿ûw.±rXxµ÷r<»WYyµßWëR|M!‹¤¥bB•˜Ï©Ø€(E¯₫` 41ú°O1KÜYù¿‚ܶÇ5ÏU®´w ÙXôâ\e�æ²SÍ‹C[+öÎGv­zṇ̃Í>ØÈË7[đ‘p¥hÅaF%;lÀ—'«É[ÜQ§»¿‹Âc¸Íï% ¦xë×=dÁ¨¥•pW’aLRÎj~̀aoSBâ¹JH,é`ÛU3¹•ÿ3(gr:¿LÆ´ƒJ=î®+ƒ́ê¾!ë«èáÂæí‘]w~lv!èz…ä²8Ànñ­kWâ^œƠp@VœÉ®¤ä´GÍƠÔˆºTaj›é°è÷Úº*á=%${¯¶{MÂ}0èQ ̉h?i₫·bø\JÄl®è[ êüXÛĂ÷ơ ïEÄ¡îIyÜ”8]£;0—zSųó₫đle²Û<»'—ü>‹bíVô¬íîèR2Æ}jÈw\â8°Ï–Jr¡6ÜVñVèQ¼`yú\¥Çg»Ó§º>~J7Åv ®Pêïê£íèµ8ØáèÿEËÿÚcÀWqí›Ü^�ÙT́ÀÜ)A‚À¸ §df.&Ëo<Đ̃·œW¢g¶-YxOzi™Ú–á¼ÂùÔܵ%R¸51q÷“×Â₫=,zH¶4¼â³™{<¶́nû¾7Ó7V’¨xl)[Á„+x„̃€+WÜ[Jôî'néf‡áOYDï°‰R Ù@5iRnaF¥J&ÓiÅàSœº,'0÷áG´|Ι¾“ÓÉ:mS}ă)ÆeËĐưƠÔh[ÍêI™ˆv®8zỌ~ù,fƠXvtgsç½”·êß©¾Umy+ïÀơ­6—P=Ư*¨̃vïñ´²sƠ-P[ĐTW0çâVƯM¿ƒƯK£{~i³l¨¯RÍ@·}Ø£Jâ¥K…g³Éưs±IU¥NK£2$A@e’EiF%‘#¨ÊRơï&̉z´6”=ïŸ]Z»Ô“½¢î1/fײ[Ó„.*{Ÿ$Q½J}w’H#oJ¢É¡đ{×’·Ï™đ̉€DIÏ*vkJ̃Vë’· {“é‡íK̃ÖMa»’·íA›ÄØd‘>ê ÿ€²ÉeF«ă„V+ắÓ¢\Á逄#ßx́àj#%¯À®ơQ¹ÊfûÎë¨Âmf…ƠùÛ+ª¼¦ÓŸP}Åq¾%2qƠ oÖôH€ƒỤ́=”Mhd*M!_Ó¿•ũóöÊT¾¸aBáwl†‘đÍ¥x Œ‘¿Úbf!(rƒ^që‘gÉcœ? ‚ey»µ©̃çƒÆbŸ«Ë¯vñÜ´TÙç˜Ü´`<o3¼2Ù…© ]¨G¹  óÔª”»ªÊ'Ê&Ü̉ßsôÑ3ë̀²j^®ªb±…1ň\}<W».Ÿ‚Ï©.·©́R ¢ ´M±$Xf³|KM2ļå#*xƠ‡ïÖ̉{Ïi°äOµA¹hxeØûÜÀ[:ctîÂk>‡7é(`rJ…ta$ñÅÉ ¥}™h̀…ß§~ẓ÷‰ Ë“ÄôÛư± ϧ$N¨€3=¥í$êuQ¬„´ ºß5ưt˰hvgŲ̀¢6T,zÔ–‡ßUT®~Qeœƒ*o)¥Àöa¨…I÷Å;íûl™¼Ẁp%´¦`’¿) Uüt¥“ ó)ó¦Ê.H^˜ø‘Oäô)*û¬Ú$uÅ/•Xä ·ÔrU¯kÓ·fƠ,5³êÎ… ƒ2Ă6ơÛdçV¬µ̀¼³€¼:fÍÓÈçă1„d‰ERRu »:‘׬À³yăPDYVc’å{„¥+2x7¦Ä6Ï.wEĐúKU™î°˜¡l²g1£Oÿ±©rÑ£₫Ô"ÿ®¢§2ö=ˆ¡•1*’ï ’J`=„hBW£B,jo­°ï‰’<«¼´`œ afñăéÑơkĐ‹Ë^¯Ô¸EV?ÂdX½ë[_Q¤-7'hÈgÔ7ö>Æi’ ÚxÉ„¿±r­! Ø̀¨¨Xµ¹^¢m­Ïº¢.aÅ1}¸X/±¬:+♹̣*ºª ×8 u\ÙĐ »+Û¤RןY/t¾ø”̣ÄÈ ưwÍÓöz\)Û»G¥B̃U[p6ª ó)5C̀Ê_e›y¯/‚�tê…½V‡ê€Ï瑜²1â jJTÖ•M­úXză%È9I>¯~(rEªªÔála¹y7vă±^ëˆ,Ơ¾Ǿ˜ÁˆÎ‡ĐÈ¿è .†«› Ậ;Qø¾ßñ i 9%" ¾íĂÏ$‚8‰\-,đ¼ Z¸p&|øÆï»đN xØÜ|̣ï°§.3üÓ̀ÿ43Y/nZÈîbríœîEh®™ÁAEèr'Z ü» ÓN»Øù¸RQĂ0̀-ïzÅ3áF̃½î|UWrvQs\4ú‘“lƒ¹xóh ́ưy™½ïá<ºO››rW6æêr ,,3+â¶¶®©Ă’¹Ô†IOЄ·<Œ ­¥`GÙ¤ŸQ¤ÚÀ ̀Ïo:GÛ­Äs ]w Üx̉[‡h(ơ9°³î�¸l8�vÿ©„Z ™å¬úçJÿQ¯GÜ_â“i×Îÿ¢Ôc#������4�3�.�4�.�2� �@�b�l�k�s�p�a�r�s�e�/�b�l�k�s�p�a�r�s�e������h�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�b�l�k�s�p�a�r�s�e�_�0�0�2�f�c�t�r�a�n�s�p�o�s�e���6�3�.�4�.�3� �@�b�l�k�s�p�a�r�s�e�/�c�t�r�a�n�s�p�o�s�e������b�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�b�l�k�s�p�a�r�s�e�_�0�0�2�f�d�i�s�p�l�a�y���0�3�.�4�.�4� �@�b�l�k�s�p�a�r�s�e�/�d�i�s�p�l�a�y������\�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�b�l�k�s�p�a�r�s�e�_�0�0�2�f�f�u�l�l���*�3�.�4�.�5� �@�b�l�k�s�p�a�r�s�e�/�f�u�l�l������d�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�b�l�k�s�p�a�r�s�e�_�0�0�2�f�i�s�m�a�t�r�i�x���2�3�.�4�.�6� �@�b�l�k�s�p�a�r�s�e�/�i�s�m�a�t�r�i�x������`�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�b�l�k�s�p�a�r�s�e�_�0�0�2�f�i�s�r�e�a�l���.�3�.�4�.�7� �@�b�l�k�s�p�a�r�s�e�/�i�s�r�e�a�l������d�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�b�l�k�s�p�a�r�s�e�_�0�0�2�f�i�s�s�p�a�r�s�e���2�3�.�4�.�8� �@�b�l�k�s�p�a�r�s�e�/�i�s�s�p�a�r�s�e������^�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�b�l�k�s�p�a�r�s�e�_�0�0�2�f�m�i�n�u�s���,�3�.�4�.�9� �@�b�l�k�s�p�a�r�s�e�/�m�i�n�u�s������d�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�b�l�k�s�p�a�r�s�e�_�0�0�2�f�m�l�d�i�v�i�d�e���4�3�.�4�.�1�0� �@�b�l�k�s�p�a�r�s�e�/�m�l�d�i�v�i�d�e������d�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�b�l�k�s�p�a�r�s�e�_�0�0�2�f�m�r�d�i�v�i�d�e���4�3�.�4�.�1�1� �@�b�l�k�s�p�a�r�s�e�/�m�r�d�i�v�i�d�e������`�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�b�l�k�s�p�a�r�s�e�_�0�0�2�f�m�t�i�m�e�s���0�3�.�4�.�1�2� �@�b�l�k�s�p�a�r�s�e�/�m�t�i�m�e�s������\�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�b�l�k�s�p�a�r�s�e�_�0�0�2�f�p�l�u�s���,�3�.�4�.�1�3� �@�b�l�k�s�p�a�r�s�e�/�p�l�u�s������\�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�b�l�k�s�p�a�r�s�e�_�0�0�2�f�s�i�z�e���,�3�.�4�.�1�4� �@�b�l�k�s�p�a�r�s�e�/�s�i�z�e������`�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�b�l�k�s�p�a�r�s�e�_�0�0�2�f�s�p�a�r�s�e���0�3�.�4�.�1�5� �@�b�l�k�s�p�a�r�s�e�/�s�p�a�r�s�e������b�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�b�l�k�s�p�a�r�s�e�_�0�0�2�f�s�u�b�s�r�e�f���2�3�.�4�.�1�6� �@�b�l�k�s�p�a�r�s�e�/�s�u�b�s�r�e�f������f�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�b�l�k�s�p�a�r�s�e�_�0�0�2�f�t�r�a�n�s�p�o�s�e���6�3�.�4�.�1�7� �@�b�l�k�s�p�a�r�s�e�/�t�r�a�n�s�p�o�s�e������`�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�b�l�k�s�p�a�r�s�e�_�0�0�2�f�u�m�i�n�u�s���0�3�.�4�.�1�8� �@�b�l�k�s�p�a�r�s�e�/�u�m�i�n�u�s������^�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�b�l�k�s�p�a�r�s�e�_�0�0�2�f�u�p�l�u�s���.�3�.�4�.�1�9� �@�b�l�k�s�p�a�r�s�e�/�u�p�l�u�s������L�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�K�r�o�n�e�c�k�e�r�-�P�r�o�d�u�c�t�s���,�3�.�5� �K�r�o�n�e�c�k�e�r� �P�r�o�d�u�c�t�s������`�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�c�o�l�u�m�n�s���.�3�.�5�.�1� �@�k�r�o�n�p�r�o�d�/�c�o�l�u�m�n�s������f�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�c�t�r�a�n�s�p�o�s�e���4�3�.�5�.�2� �@�k�r�o�n�p�r�o�d�/�c�t�r�a�n�s�p�o�s�e������X�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�d�e�t���&�3�.�5�.�3� �@�k�r�o�n�p�r�o�d�/�d�e�t������Z�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�d�i�s�p���(�3�.�5�.�4� �@�k�r�o�n�p�r�o�d�/�d�i�s�p������`�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�d�i�s�p�l�a�y���.�3�.�5�.�5� �@�k�r�o�n�p�r�o�d�/�d�i�s�p�l�a�y������Z�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�f�u�l�l���(�3�.�5�.�6� �@�k�r�o�n�p�r�o�d�/�f�u�l�l������X�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�i�n�v���&�3�.�5�.�7� �@�k�r�o�n�p�r�o�d�/�i�n�v������d�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�i�s�c�o�m�p�l�e�x���2�3�.�5�.�8� �@�k�r�o�n�p�r�o�d�/�i�s�c�o�m�p�l�e�x������b�l�i�n�e�a�r�-�a�l�g�e�b�r�����a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�i�s�m�a�t�r�i�x���0�3�.�5�.�9� �@�k�r�o�n�p�r�o�d�/�i�s�m�a�t�r�i�x������^�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�i�s�r�e�a�l���.�3�.�5�.�1�0� �@�k�r�o�n�p�r�o�d�/�i�s�r�e�a�l������b�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�i�s�s�p�a�r�s�e���2�3�.�5�.�1�1� �@�k�r�o�n�p�r�o�d�/�i�s�s�p�a�r�s�e������b�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�i�s�s�q�u�a�r�e���2�3�.�5�.�1�2� �@�k�r�o�n�p�r�o�d�/�i�s�s�q�u�a�r�e������b�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�k�r�o�n�p�r�o�d���2�3�.�5�.�1�3� �@�k�r�o�n�p�r�o�d�/�k�r�o�n�p�r�o�d������\�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�m�i�n�u�s���,�3�.�5�.�1�4� �@�k�r�o�n�p�r�o�d�/�m�i�n�u�s������b�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�m�l�d�i�v�i�d�e���2�3�.�5�.�1�5� �@�k�r�o�n�p�r�o�d�/�m�l�d�i�v�i�d�e������^�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�m�p�o�w�e�r���.�3�.�5�.�1�6� �@�k�r�o�n�p�r�o�d�/�m�p�o�w�e�r������^�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�m�t�i�m�e�s���.�3�.�5�.�1�7� �@�k�r�o�n�p�r�o�d�/�m�t�i�m�e�s������\�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�n�u�m�e�l���,�3�.�5�.�1�8� �@�k�r�o�n�p�r�o�d�/�n�u�m�e�l������Z�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�p�l�u�s���*�3�.�5�.�1�9� �@�k�r�o�n�p�r�o�d�/�p�l�u�s������Z�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�r�a�n�k���*�3�.�5�.�2�0� �@�k�r�o�n�p�r�o�d�/�r�a�n�k������`�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�r�d�i�v�i�d�e���0�3�.�5�.�2�1� �@�k�r�o�n�p�r�o�d�/�r�d�i�v�i�d�e������Z�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�r�o�w�s���*�3�.�5�.�2�2� �@�k�r�o�n�p�r�o�d�/�r�o�w�s������Z�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�s�i�z�e���*�3�.�5�.�2�3� �@�k�r�o�n�p�r�o�d�/�s�i�z�e������n�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�s�i�z�e�_�0�0�5�f�e�q�u�a�l���6�3�.�5�.�2�4� �@�k�r�o�n�p�r�o�d�/�s�i�z�e�_�e�q�u�a�l������^�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�s�p�a�r�s�e���.�3�.�5�.�2�5� �@�k�r�o�n�p�r�o�d�/�s�p�a�r�s�e������\�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�t�i�m�e�s���,�3�.�5�.�2�6� �@�k�r�o�n�p�r�o�d�/�t�i�m�e�s������\�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�t�r�a�c�e���,�3�.�5�.�2�7� �@�k�r�o�n�p�r�o�d�/�t�r�a�c�e������d�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�t�r�a�n�s�p�o�s�e���4�3�.�5�.�2�8� �@�k�r�o�n�p�r�o�d�/�t�r�a�n�s�p�o�s�e������^�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�u�m�i�n�u�s���.�3�.�5�.�2�9� �@�k�r�o�n�p�r�o�d�/�u�m�i�n�u�s������\�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�g�_�t�_�0�0�4�0�k�r�o�n�p�r�o�d�_�0�0�2�f�u�p�l�u�s���,�3�.�5�.�3�0� �@�k�r�o�n�p�r�o�d�/�u�p�l�u�s������L�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�C�i�r�c�u�l�a�n�t�-�m�a�t�r�i�c�e�s���,�3�.�6� �C�i�r�c�u�l�a�n�t� �m�a�t�r�i�c�e�s������J�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�c�i�r�c�u�l�a�n�t�_�0�0�5�f�e�i�g���&�3�.�6�.�1� �c�i�r�c�u�l�a�n�t�_�e�i�g������J�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�c�i�r�c�u�l�a�n�t�_�0�0�5�f�i�n�v���&�3�.�6�.�2� �c�i�r�c�u�l�a�n�t�_�i�n�v������b�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�c�i�r�c�u�l�a�n�t�_�0�0�5�f�m�a�k�e�_�0�0�5�f�m�a�t�r�i�x���6�3�.�6�.�3� �c�i�r�c�u�l�a�n�t�_�m�a�k�e�_�m�a�t�r�i�x������~�l�i�n�e�a�r�-�a�l�g�e�b�r�a�.�h�t�m�l�#�c�i�r�c�u�l�a�n�t�_�0�0�5�f�m�a�t�r�i�x�_�0�0�5�f�v�e�c�t�o�r�_�0�0�5�f�p�r�o�d�u�c�t���J�3�.�6�.�4� �c�i�r�c�u�l�a�n�t�_�m�a�t�r�i�x�_�v�e�c�t�o�r�_�p�r�o�d�u�c�tlinear-algebra-2.2.4/doc/PaxHeaders/macros.texi�����������������������������������������������������0000644�0000000�0000000�00000000062�15146653315�016401� x����������������������������������������������������������������������������������������������������ustar�00�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������20 atime=1771787981 30 ctime=1771788142.228370636 ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������linear-algebra-2.2.4/doc/macros.texi����������������������������������������������������������������0000644�0001750�0001750�00000006241�15146653315�016720� 0����������������������������������������������������������������������������������������������������ustar�00philip��������������������������philip�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������@c Copyright (C) 2012-2026 John W. Eaton @c @c This file is part of Octave. @c @c Octave is free software: you can redistribute it and/or modify it @c under the terms of the GNU General Public License as published by @c the Free Software Foundation, either version 3 of the License, or @c (at your option) any later version. @c @c Octave is distributed in the hope that it will be useful, but @c WITHOUT ANY WARRANTY; without even the implied warranty of @c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @c GNU General Public License for more details. @c @c You should have received a copy of the GNU General Public License @c along with Octave; see the file COPYING. If not, see @c <https://www.gnu.org/licenses/>. @c The following macro marks words that aspell should ignore during @c spellchecking. Within Texinfo it has no effect as it merely replaces @c the macro call with the argument itself. @macro nospell {arg} \arg\ @end macro @c The following macro works around the Info/plain text expansion of @code{XXX} @c which is `XXX'. This looks particularly bad when the macro body is @c single or double-quoted text, such as a property value `"position"' @ifinfo @macro qcode{arg} \arg\ @end macro @end ifinfo @ifnotinfo @macro qcode{arg} @code{\arg\} @end macro @end ifnotinfo @c The following macro is used for the on-line help system, but we don't @c want lots of `See also: foo, bar, and baz' strings cluttering the @c printed manual (that information should be in the supporting text for @c each group of functions and variables). @c @c Implementation Note: @c For TeX, @vskip produces a nice separation. @c For Texinfo, '@sp 1' should work, but in practice produces ugly results @c for HTML. We use a simple blank line to produce the correct @c behavior. @c @c We use @xseealso now because Texinfo introduced its own @seealso @c command. But instead of modifying all source files, we'll have the @c munge-texi script convert @seealso to @xseealso. @macro xseealso {args} @iftex @vskip 2pt @end iftex @ifnottex @end ifnottex @ifnotinfo @noindent @strong{See also:} \args\. @end ifnotinfo @ifinfo @noindent See also: \args\. @end ifinfo @end macro @c The following macro works around a situation where the Info/plain text @c expansion of the @code{XXX} macro is `XXX'. The use of the apostrophe @c can be confusing if the code segment itself ends with a transpose operator. @ifinfo @macro tcode{arg} \arg\ @end macro @end ifinfo @ifnotinfo @macro tcode{arg} @code{\arg\} @end macro @end ifnotinfo @c FIXME: someday, when Texinfo 5.X is standard, we might replace this with @c @backslashchar, which is a new addition to Texinfo. @macro xbackslashchar \\ @end macro @c These may be useful for all, not just for octave.texi. @tex \ifx\rgbDarkRed\thisisundefined \def\rgbDarkRed{0.50 0.09 0.12} \fi \ifx\linkcolor\thisisundefined \relax \else \global\def\linkcolor{\rgbDarkRed} \fi \ifx\urlcolor\thisisundefined \relax \else \global\def\urlcolor{\rgbDarkRed} \fi \ifx\urefurlonlylinktrue\thisisundefined \relax \else \global\urefurlonlylinktrue \fi @end tex @c Make the apostrophe in code examples cut-and-paste friendly. @codequoteundirected on ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������linear-algebra-2.2.4/doc/PaxHeaders/linear-algebra.texi���������������������������������������������0000644�0000000�0000000�00000000062�15146653315�017762� x����������������������������������������������������������������������������������������������������ustar�00�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������20 atime=1771787981 30 ctime=1771788142.228370636 ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������linear-algebra-2.2.4/doc/linear-algebra.texi��������������������������������������������������������0000644�0001750�0001750�00000007576�15146653315�020315� 0����������������������������������������������������������������������������������������������������ustar�00philip��������������������������philip�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������% Copyright (C) 1996-2026 The Octave Project Developers % % This file is part of Octave. % % Octave is free software: you can redistribute it and/or modify it % under the terms of the GNU General Public License as published by % the Free Software Foundation, either version 3 of the License, or % (at your option) any later version. % % Octave is distributed in the hope that it will be useful, but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with Octave; see the file COPYING. If not, see % <https://www.gnu.org/licenses/>. \input texinfo @c Octave linear-algebra - linear-algebra package for GNU octave. @c For manually generating the documentation use @c LANGUAGE=en makeinfo --html --no-split linear-algebra.texi @c %*** Start of HEADER @documentencoding UTF-8 @setfilename linear-algebra.info @settitle Octave linear-algebra - linear-algebra package for GNU octave @afourpaper @paragraphindent 0 @finalout @c @afourwide @c %*** End of the HEADER @dircategory Math @direntry * Octave linear-algebra: (linear-algebra). linear-algebra package for Octave @end direntry @include version.texi @include macros.texi @c ------------------------------------------------------------------------- @c @contents @c ------------------------------------------------------------------------- @ifnottex @node Top @top Octave linear-algebra package Copyright © The Octave Project Developers Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions. @end ifnottex @c ------------------------------------------------------------------------- @node Overview @chapter Overview @cindex Overview The linear-algebra package contains additional linear algebra functions. @c ------------------------------------------------------------------------- @node Installing and loading @chapter Installing and loading @cindex Installing and loading The linear-algebra package must be installed and then loaded to be used. It can be installed in @acronym{GNU} Octave directly from octave-forge, @section Windows install @cindex Windows install If running in Windows, the package may already be installed, to check run: @example pkg list linear-algebra @end example @section Installing @cindex Installing With an internet connection available, the linear-algebra package can be installed from packages.octave.org using the following command within @acronym{GNU} Octave: @example pkg install linear-algebra @end example The latest released version of the package will be downloaded and installed. Otherwise, if the package file has already been downloaded it can be installed using the following command in @acronym{GNU} Octave: @example pkg install linear-algebra-@value{VERSION}.tar.gz @end example @section Loading @cindex Loading Regardless of the method of installing the package, in order to use its functions, the package must be loaded using the pkg load command: @example pkg load linear-algebra @end example The package must be loaded on each @acronym{GNU} Octave session. @c ------------------------------------------------------------------------- @node Function Reference @chapter Function Reference @cindex Function Reference @include functions.texi @c ------------------------------------------------------------------------- @bye ����������������������������������������������������������������������������������������������������������������������������������linear-algebra-2.2.4/doc/PaxHeaders/linear-algebra.info���������������������������������������������0000644�0000000�0000000�00000000062�15146653315�017744� x����������������������������������������������������������������������������������������������������ustar�00�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������20 atime=1771787981 30 ctime=1771788142.228370636 ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������linear-algebra-2.2.4/doc/linear-algebra.info��������������������������������������������������������0000644�0001750�0001750�00000120523�15146653315�020263� 0����������������������������������������������������������������������������������������������������ustar�00philip��������������������������philip�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������This is linear-algebra.info, produced by makeinfo version 7.2 from linear-algebra.texi. INFO-DIR-SECTION Math START-INFO-DIR-ENTRY * Octave linear-algebra: (linear-algebra). linear-algebra package for Octave END-INFO-DIR-ENTRY  File: linear-algebra.info, Node: Top, Next: Overview, Up: (dir) Octave linear-algebra package ***************************** Copyright © The Octave Project Developers Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions. * Menu: * Overview:: * Installing and loading:: * Function Reference:: -- The Detailed Node Listing -- Function Reference * Vector functions:: * Matrix functions:: * Matrix factorization:: * Block sparse matrices:: * Kronecker Products:: * Circulant matrices::  File: linear-algebra.info, Node: Overview, Next: Installing and loading, Prev: Top, Up: Top 1 Overview ********** The linear-algebra package contains additional linear algebra functions.  File: linear-algebra.info, Node: Installing and loading, Next: Function Reference, Prev: Overview, Up: Top 2 Installing and loading ************************ The linear-algebra package must be installed and then loaded to be used. It can be installed in GNU Octave directly from octave-forge, 2.1 Windows install =================== If running in Windows, the package may already be installed, to check run: pkg list linear-algebra 2.2 Installing ============== With an internet connection available, the linear-algebra package can be installed from packages.octave.org using the following command within GNU Octave: pkg install linear-algebra The latest released version of the package will be downloaded and installed. Otherwise, if the package file has already been downloaded it can be installed using the following command in GNU Octave: pkg install linear-algebra-2.2.4.tar.gz 2.3 Loading =========== Regardless of the method of installing the package, in order to use its functions, the package must be loaded using the pkg load command: pkg load linear-algebra The package must be loaded on each GNU Octave session.  File: linear-algebra.info, Node: Function Reference, Prev: Installing and loading, Up: Top 3 Function Reference ******************** * Menu: * Vector functions:: * Matrix functions:: * Matrix factorization:: * Block sparse matrices:: * Kronecker Products:: * Circulant matrices::  File: linear-algebra.info, Node: Vector functions, Next: Matrix functions, Up: Function Reference 3.1 Vector functions ==================== 3.1.1 vec_projection -------------------- -- Function File: OUT = vec_projection (X, Y) Compute the vector projection of a 3-vector onto another. X : size 1 x 3 and Y : size 1 x 3 TOL : size 1 x 1 vec_projection ([1,0,0], [0.5,0.5,0]) ⇒ 0.7071 Vector projection of X onto Y, both are 3-vectors, returning the value of X along Y. Function uses dot product, Euclidean norm, and angle between vectors to compute the proper length along Y.  File: linear-algebra.info, Node: Matrix functions, Next: Matrix factorization, Prev: Vector functions, Up: Function Reference 3.2 Matrix functions ==================== 3.2.1 cartprod -------------- -- Function File: cartprod (VARARGIN) Computes the cartesian product of given column vectors ( row vectors ). The vector elements are assumend to be numbers. Alternatively the vectors can be specified by as a matrix, by its columns. To calculate the cartesian product of vectors, P = A x B x C x D ... . Requires A, B, C, D be column vectors. The algorithm is iteratively calcualte the products, ( ( (A x B ) x C ) x D ) x etc. cartprod(1:2,3:4,0:1) ans = 1 3 0 2 3 0 1 4 0 2 4 0 1 3 1 2 3 1 1 4 1 2 4 1 See also: kron. 3.2.2 cod --------- -- Function File: [Q, R, Z] = cod (A) -- Function File: [Q, R, Z, P] = cod (A) -- Function File: [...] = cod (A, '0') Computes the complete orthogonal decomposition (COD) of the matrix A: A = Q*R*Z' Let A be an M-by-N matrix, and let ‘K = min(M, N)’. Then Q is M-by-M orthogonal, Z is N-by-N orthogonal, and R is M-by-N such that ‘R(:,1:K)’ is upper trapezoidal and ‘R(:,K+1:N)’ is zero. The additional P output argument specifies that pivoting should be used in the first step (QR decomposition). In this case, A*P = Q*R*Z' If a second argument of '0' is given, an economy-sized factorization is returned so that R is K-by-K. _NOTE_: This is currently implemented by double QR factorization plus some tricky manipulations, and is not as efficient as using xRZTZF from LAPACK. See also: qr. 3.2.3 funm ---------- -- Function File: B = funm (A, F) Compute matrix equivalent of function F; F can be a function name or a function handle and A must be a square matrix. For trigonometric and hyperbolic functions, ‘thfm’ is automatically invoked as that is based on ‘expm’ and diagonalization is avoided. For other functions diagonalization is invoked, which implies that -depending on the properties of input matrix A- the results can be very inaccurate _without any warning_. For easy diagonizable and stable matrices the results of funm will be sufficiently accurate. Note that you should not use funm for 'sqrt', 'log' or 'exp'; instead use sqrtm, logm and expm as these are more robust. Examples: B = funm (A, sin); (Compute matrix equivalent of sin() ) function bk1 = besselk1 (x) bk1 = besselk(1, x); endfunction B = funm (A, besselk1); (Compute matrix equivalent of bessel function K1(); a helper function is needed here to convey extra arguments for besselk() ) Note that a much improved funm.m function has been implemented in Octave 11.1.0, so funm.m will be removed from the linear-algebra package if that is installed in Octave 11+. See also: thfm, expm, logm, sqrtm. 3.2.4 lobpcg ------------ -- Function File: [BLOCKVECTORX, LAMBDA] = lobpcg (BLOCKVECTORX, OPERATORA) -- Function File: [BLOCKVECTORX, LAMBDA, FAILUREFLAG] = lobpcg (BLOCKVECTORX, OPERATORA) -- Function File: [BLOCKVECTORX, LAMBDA, FAILUREFLAG, LAMBDAHISTORY, RESIDUALNORMSHISTORY] = lobpcg (BLOCKVECTORX, OPERATORA, OPERATORB, OPERATORT, BLOCKVECTORY, RESIDUALTOLERANCE, MAXITERATIONS, VERBOSITYLEVEL) Solves Hermitian partial eigenproblems using preconditioning. The first form outputs the array of algebraic smallest eigenvalues LAMBDA and corresponding matrix of orthonormalized eigenvectors BLOCKVECTORX of the Hermitian (full or sparse) operator OPERATORA using input matrix BLOCKVECTORX as an initial guess, without preconditioning, somewhat similar to: # for real symmetric operator operatorA opts.issym = 1; opts.isreal = 1; K = size (blockVectorX, 2); [blockVectorX, lambda] = eigs (operatorA, K, 'SR', opts); # for Hermitian operator operatorA K = size (blockVectorX, 2); [blockVectorX, lambda] = eigs (operatorA, K, 'SR'); The second form returns a convergence flag. If FAILUREFLAG is 0 then all the eigenvalues converged; otherwise not all converged. The third form computes smallest eigenvalues LAMBDA and corresponding eigenvectors BLOCKVECTORX of the generalized eigenproblem Ax=lambda Bx, where Hermitian operators OPERATORA and OPERATORB are given as functions, as well as a preconditioner, OPERATORT. The operators OPERATORB and OPERATORT must be in addition _positive definite_. To compute the largest eigenpairs of OPERATORA, simply apply the code to OPERATORA multiplied by -1. The code does not involve _any_ matrix factorizations of OPERATORA and OPERATORB, thus, e.g., it preserves the sparsity and the structure of OPERATORA and OPERATORB. RESIDUALTOLERANCE and MAXITERATIONS control tolerance and max number of steps, and VERBOSITYLEVEL = 0, 1, or 2 controls the amount of printed info. LAMBDAHISTORY is a matrix with all iterative lambdas, and RESIDUALNORMSHISTORY are matrices of the history of 2-norms of residuals Required input: • BLOCKVECTORX (class numeric) - initial approximation to eigenvectors, full or sparse matrix n-by-blockSize. BLOCKVECTORX must be full rank. • OPERATORA (class numeric, char, or function_handle) - the main operator of the eigenproblem, can be a matrix, a function name, or handle Optional function input: • OPERATORB (class numeric, char, or function_handle) - the second operator, if solving a generalized eigenproblem, can be a matrix, a function name, or handle; by default if empty, ‘operatorB = I’. • OPERATORT (class char or function_handle) - the preconditioner, by default ‘operatorT(blockVectorX) = blockVectorX’. Optional constraints input: • BLOCKVECTORY (class numeric) - a full or sparse n-by-sizeY matrix of constraints, where sizeY < n. BLOCKVECTORY must be full rank. The iterations will be performed in the (operatorB-) orthogonal complement of the column-space of BLOCKVECTORY. Optional scalar input parameters: • RESIDUALTOLERANCE (class numeric) - tolerance, by default, ‘residualTolerance = n * sqrt (eps)’ • MAXITERATIONS - max number of iterations, by default, ‘maxIterations = min (n, 20)’ • VERBOSITYLEVEL - either 0 (no info), 1, or 2 (with pictures); by default, ‘verbosityLevel = 0’. Required output: • BLOCKVECTORX and LAMBDA (class numeric) both are computed blockSize eigenpairs, where ‘blockSize = size (blockVectorX, 2)’ for the initial guess BLOCKVECTORX if it is full rank. Optional output: • FAILUREFLAG (class integer) as described above. • LAMBDAHISTORY (class numeric) as described above. • RESIDUALNORMSHISTORY (class numeric) as described above. Functions ‘operatorA(blockVectorX)’, ‘operatorB(blockVectorX)’ and ‘operatorT(blockVectorX)’ must support BLOCKVECTORX being a matrix, not just a column vector. Every iteration involves one application of OPERATORA and OPERATORB, and one of OPERATORT. Main memory requirements: 6 (9 if ‘isempty(operatorB)=0’) matrices of the same size as BLOCKVECTORX, 2 matrices of the same size as BLOCKVECTORY (if present), and two square matrices of the size 3*blockSize. In all examples below, we use the Laplacian operator in a 20x20 square with the mesh size 1 which can be generated in MATLAB by running: A = delsq (numgrid ('S', 21)); n = size (A, 1); or in MATLAB and Octave by: [~,~,A] = laplacian ([19, 19]); n = size (A, 1); Note that ‘laplacian’ is a function of the specfun octave-forge package. The following Example: [blockVectorX, lambda, failureFlag] = lobpcg (randn (n, 8), A, 1e-5, 50, 2); attempts to compute 8 first eigenpairs without preconditioning, but not all eigenpairs converge after 50 steps, so failureFlag=1. The next Example: blockVectorY = []; lambda_all = []; for j = 1:4 [blockVectorX, lambda] = lobpcg (randn (n, 2), A, blockVectorY, 1e-5, 200, 2); blockVectorY = [blockVectorY, blockVectorX]; lambda_all = [lambda_all' lambda']'; pause; end attemps to compute the same 8 eigenpairs by calling the code 4 times with blockSize=2 using orthogonalization to the previously founded eigenvectors. The following Example: R = ichol (A, struct('michol', 'on')); precfun = @(x)R\(R'\x); [blockVectorX, lambda, failureFlag] = lobpcg (randn (n, 8), A, [], @(x)precfun(x), 1e-5, 60, 2); computes the same eigenpairs in less then 25 steps, so that failureFlag=0 using the preconditioner function ‘precfun’, defined inline. If ‘precfun’ is defined as an octave function in a file, the function handle ‘@(x)precfun(x)’ can be equivalently replaced by the function name ‘precfun’. Running: [blockVectorX, lambda, failureFlag] = lobpcg (randn (n, 8), A, speye (n), @(x)precfun(x), 1e-5, 50, 2); produces similar answers, but is somewhat slower and needs more memory as technically a generalized eigenproblem with B=I is solved here. The following example for a mostly diagonally dominant sparse matrix A demonstrates different types of preconditioning, compared to the standard use of the main diagonal of A: clear all; close all; n = 1000; M = spdiags ([1:n]', 0, n, n); precfun = @(x)M\x; A = M + sprandsym (n, .1); Xini = randn (n, 5); maxiter = 15; tol = 1e-5; [~,~,~,~,rnp] = lobpcg (Xini, A, tol, maxiter, 1); [~,~,~,~,r] = lobpcg (Xini, A, [], @(x)precfun(x), tol, maxiter, 1); subplot (2,2,1), semilogy (r'); hold on; semilogy (rnp', ':>'); title ('No preconditioning (top)'); axis tight; M(1,2) = 2; precfun = @(x)M\x; % M is no longer symmetric [~,~,~,~,rns] = lobpcg (Xini, A, [], @(x)precfun(x), tol, maxiter, 1); subplot (2,2,2), semilogy (r'); hold on; semilogy (rns', '--s'); title ('Nonsymmetric preconditioning (square)'); axis tight; M(1,2) = 0; precfun = @(x)M\(x+10*sin(x)); % nonlinear preconditioning [~,~,~,~,rnl] = lobpcg (Xini, A, [], @(x)precfun(x), tol, maxiter, 1); subplot (2,2,3), semilogy (r'); hold on; semilogy (rnl', '-.*'); title ('Nonlinear preconditioning (star)'); axis tight; M = abs (M - 3.5 * speye (n, n)); precfun = @(x)M\x; [~,~,~,~,rs] = lobpcg (Xini, A, [], @(x)precfun(x), tol, maxiter, 1); subplot (2,2,4), semilogy (r'); hold on; semilogy (rs', '-d'); title ('Selective preconditioning (diamond)'); axis tight; References ========== This main function ‘lobpcg’ is a version of the preconditioned conjugate gradient method (Algorithm 5.1) described in A. V. Knyazev, Toward the Optimal Preconditioned Eigensolver: Locally Optimal Block Preconditioned Conjugate Gradient Method, SIAM Journal on Scientific Computing 23 (2001), no. 2, pp. 517-541. <http://dx.doi.org/10.1137/S1064827500366124> Known bugs/features =================== • an excessively small requested tolerance may result in often restarts and instability. The code is not written to produce an eps-level accuracy! Use common sense. • the code may be very sensitive to the number of eigenpairs computed, if there is a cluster of eigenvalues not completely included, cf. operatorA = diag ([1 1.99 2:99]); [blockVectorX, lambda] = lobpcg (randn (100, 1),operatorA, 1e-10, 80, 2); [blockVectorX, lambda] = lobpcg (randn (100, 2),operatorA, 1e-10, 80, 2); [blockVectorX, lambda] = lobpcg (randn (100, 3),operatorA, 1e-10, 80, 2); Distribution ============ The main distribution site: <http://math.ucdenver.edu/~aknyazev/> A C-version of this code is a part of the <http://code.google.com/p/blopex/> package and is directly available, e.g., in PETSc and HYPRE. 3.2.5 ndcovlt ------------- -- Function File: Y = ndcovlt (X, T1, T2, ...) Computes an n-dimensional covariant linear transform of an n-d tensor, given a transformation matrix for each dimension. The number of columns of each transformation matrix must match the corresponding extent of X, and the number of rows determines the corresponding extent of Y. For example: size (X, 2) == columns (T2) size (Y, 2) == rows (T2) The element ‘Y(i1, i2, ...)’ is defined as a sum of X(j1, j2, ...) * T1(i1, j1) * T2(i2, j2) * ... over all j1, j2, .... For two dimensions, this reduces to Y = T1 * X * T2.' [] passed as a transformation matrix is converted to identity matrix for the corresponding dimension. 3.2.6 rotparams --------------- -- Function File: [VSTACKED, ASTACKED] = rotparams (RSTACKED) The function w = rotparams (r) - Inverse to rotv(). Using, W = rotparams(R) is such that rotv(w)*r' == eye(3). If used as, [v,a]=rotparams(r) , idem, with v (1 x 3) s.t. w == a*v. 0 <= norm(w)==a <= pi :-O !! Does not check if 'r' is a rotation matrix. Ignores matrices with zero rows or with NaNs. (returns 0 for them) See also: rotv. 3.2.7 rotv ---------- -- Function File: R = rotv ( v, ang ) The functionrotv calculates a Matrix of rotation about V w/ angle |v| r = rotv(v [,ang]) Returns the rotation matrix w/ axis v, and angle, in radians, norm(v) or ang (if present). rotv(v) == w'*w + cos(a) * (eye(3)-w'*w) - sin(a) * crossmat(w) where a = norm (v) and w = v/a. v and ang may be vertically stacked : If 'v' is 2x3, then rotv( v ) == [rotv(v(1,:)); rotv(v(2,:))] See also: rotparams, rota, rot. 3.2.8 smwsolve -------------- -- Function File: X = smwsolve (A, U, V, B) -- Function File: smwsolve (SOLVER, U, V, B) Solves the square system ‘(A + U*V')*X == B’, where U and V are matrices with several columns, using the Sherman-Morrison-Woodbury formula, so that a system with A as left-hand side is actually solved. This is especially advantageous if A is diagonal, sparse, triangular or positive definite. A can be sparse or full, the other matrices are expected to be full. Instead of a matrix A, a user may alternatively provide a function SOLVER that performs the left division operation. 3.2.9 thfm ---------- -- Function File: Y = thfm (X, MODE) Trigonometric/hyperbolic functions of square matrix X. MODE must be the name of a function. Valid functions are 'sin', 'cos', 'tan', 'sec', 'csc', 'cot' and all their inverses and/or hyperbolic variants, and 'sqrt', 'log' and 'exp'. The code ‘thfm (x, 'cos')’ calculates matrix cosinus _even if_ input matrix X is _not_ diagonalizable. _Important note_: This algorithm does _not_ use an eigensystem similarity transformation. It maps the MODE functions to functions of ‘expm’, ‘logm’ and ‘sqrtm’, which are known to be robust with respect to non-diagonalizable ('defective') X. See also: funm.  File: linear-algebra.info, Node: Matrix factorization, Next: Block sparse matrices, Prev: Matrix functions, Up: Function Reference 3.3 Matrix factorization ======================== 3.3.1 nmf_bpas -------------- -- Function File: [W, H, ITER, HIS] = nmf_bpas (A, K) Nonnegative Matrix Factorization by Alternating Nonnegativity Constrained Least Squares using Block Principal Pivoting/Active Set method. This function solves one the following problems: given A and K, find W and H such that (1) minimize 1/2 * || A-WH ||_F^2 (2) minimize 1/2 * ( || A-WH ||_F^2 + alpha * || W ||_F^2 + beta * || H ||_F^2 ) (3) minimize 1/2 * ( || A-WH ||_F^2 + alpha * || W ||_F^2 + beta * (sum_(i=1)^n || H(:,i) ||_1^2 ) ) where W>=0 and H>=0 elementwise. The input arguments are A : Input data matrix (m x n) and K : Target low-rank. *Optional Inputs* ‘Type’ Default is 'regularized', which is recommended for quick application testing unless 'sparse' or 'plain' is explicitly needed. If sparsity is needed for 'W' factor, then apply this function for the transpose of 'A' with formulation (3). Then, exchange 'W' and 'H' and obtain the transpose of them. Imposing sparsity for both factors is not recommended and thus not included in this software. 'plain' to use formulation (1) 'regularized' to use formulation (2) 'sparse' to use formulation (3) ‘NNLSSolver’ Default is 'bp', which is in general faster. 'bp' to use the algorithm in [1] 'as' to use the algorithm in [2] ‘Alpha’ Parameter alpha in the formulation (2) or (3). Default is the average of all elements in A. No good justfication for this default value, and you might want to try other values. ‘Beta’ Parameter beta in the formulation (2) or (3). Default is the average of all elements in A. No good justfication for this default value, and you might want to try other values. ‘MaxIter’ Maximum number of iterations. Default is 100. ‘MinIter’ Minimum number of iterations. Default is 20. ‘MaxTime’ Maximum amount of time in seconds. Default is 100,000. ‘Winit’ (m x k) initial value for W. ‘Hinit’ (k x n) initial value for H. ‘Tol’ Stopping tolerance. Default is 1e-3. If you want to obtain a more accurate solution, decrease TOL and increase MAX_ITER at the same time. ‘Verbose’ If present the function will show information during the calculations. *Outputs* ‘W’ Obtained basis matrix (m x k) ‘H’ Obtained coefficients matrix (k x n) ‘iter’ Number of iterations ‘HIS’ If present the history of computation is returned. Usage Examples: nmf_bpas (A,10) nmf_bpas (A,20,'verbose') nmf_bpas (A,30,'verbose','nnlssolver','as') nmf_bpas (A,5,'verbose','type','sparse') nmf_bpas (A,60,'verbose','type','plain','Winit',rand(size(A,1),60)) nmf_bpas (A,70,'verbose','type','sparse','nnlssolver','bp','alpha',1.1,'beta',1.3) References: [1] For using this software, please cite: Jingu Kim and Haesun Park, Toward Faster Nonnegative Matrix Factorization: A New Algorithm and Comparisons, In Proceedings of the 2008 Eighth IEEE International Conference on Data Mining (ICDM'08), 353-362, 2008 [2] If you use 'nnls_solver'='as' (see below), please cite: Hyunsoo Kim and Haesun Park, Nonnegative Matrix Factorization Based on Alternating Nonnegativity Constrained Least Squares and Active Set Method, SIAM Journal on Matrix Analysis and Applications, 2008, 30, 713-730 Check original code at <http://www.cc.gatech.edu/~jingu> See also: nmf_pg. 3.3.2 nmf_pg ------------ -- Function File: [W, H] = nmf_pg (V, WINIT, HINIT, TOL, TIMELIMIT, MAXITER) Non-negative matrix factorization by alternative non-negative least squares using projected gradients. The matrix V is factorized into two possitive matrices W and H such that ‘V = W*H + U’. Where U is a matrix of residuals that can be negative or positive. When the matrix V is positive the order of the elements in U is bounded by the optional named argument TOL (default value ‘1e-9’). The factorization is not unique and depends on the inital guess for the matrices W and H. You can pass this initalizations using the optional named arguments WINIT and HINIT. timelimit, maxiter: limit of time and iterations Examples: A = rand(10,5); [W H] = nmf_pg(A,tol=1e-3); U = W*H -A; disp(max(abs(U)));  File: linear-algebra.info, Node: Block sparse matrices, Next: Kronecker Products, Prev: Matrix factorization, Up: Function Reference 3.4 Block sparse matrices ========================= 3.4.1 @blksparse/blksize ------------------------ -- Function File: blksize (X) Returns the block size of the matrix. 3.4.2 @blksparse/blksparse -------------------------- -- Function File: S = blksparse (I, J, SV) -- Function File: S = blksparse (I, J, SV, M, N) -- Function File: S = blksparse (..., MODE) Construct a block sparse matrix. The meaning of arguments is analogous to the built-in ‘sparse’ function, except that I, J are indices of blocks rather than elements, and SV is a 3-dimensional array, the first two dimensions determining the block size. Optionally, M and N can be specified as the true block dimensions; if not, the maximum values of I, J are taken instead. The resulting sparse matrix has the size [M*P, N*Q] where P = size (SV, 1) Q = size (SV, 2) The blocks are located so that S(I(k):I(k)+P-1, J(k):J(K)+Q-1) = SV(:,:,k) Multiple blocks corresponding to the same pair of indices are summed, unless MODE is "unique", in which case the last of them is used. 3.4.3 @blksparse/ctranspose --------------------------- -- Function File: ctranspose (X) Returns the conjugate transpose of a block sparse matrix X. 3.4.4 @blksparse/display ------------------------ -- Function File: display (X) Displays the block sparse matrix. 3.4.5 @blksparse/full --------------------- -- Function File: full (X) Converts a block sparse matrix to full. 3.4.6 @blksparse/ismatrix ------------------------- -- Function File: ismatrix (S) Returns true (a blksparse object is a matrix). 3.4.7 @blksparse/isreal ----------------------- -- Function File: isreal (S) Returns true if the array is non-complex. 3.4.8 @blksparse/issparse ------------------------- -- Function File: issparse (S) Returns true since a blksparse is sparse by definition. 3.4.9 @blksparse/minus ---------------------- -- Function File: minus (S1, S2) Subtract two blksparse objects. 3.4.10 @blksparse/mldivide -------------------------- -- Function File: mldivide (X, Y) Performs a left division with a block sparse matrix. If X is a block sparse matrix, it must be either diagonal or triangular, and Y must be full. If X is built-in sparse or full, Y is converted accordingly, then the built-in division is used. 3.4.11 @blksparse/mrdivide -------------------------- -- Function File: mrdivide (X, Y) Performs a left division with a block sparse matrix. If Y is a block sparse matrix, it must be either diagonal or triangular, and X must be full. If Y is built-in sparse or full, X is converted accordingly, then the built-in division is used. 3.4.12 @blksparse/mtimes ------------------------ -- Function File: mtimes (X, Y) Multiplies a block sparse matrix with a full matrix, or two block sparse matrices. Multiplication of block sparse * sparse is not implemented. If one of arguments is a scalar, it's a scalar multiply. 3.4.13 @blksparse/plus ---------------------- -- Function File: plus (S1, S2) Add two blksparse objects. 3.4.14 @blksparse/size ---------------------- -- Function File: size (X) Returns the size of the matrix. 3.4.15 @blksparse/sparse ------------------------ -- Function File: sparse (X) Converts a block sparse matrix to (built-in) sparse. 3.4.16 @blksparse/subsref ------------------------- -- Function File: subsref (S, SUBS) Index elements from a blksparse object. 3.4.17 @blksparse/transpose --------------------------- -- Function File: transpose (X) Returns the transpose of a block sparse matrix X. 3.4.18 @blksparse/uminus ------------------------ -- Function File: uminus (X) Returns the negative of a block sparse matrix X. 3.4.19 @blksparse/uplus ----------------------- -- Function File: uplus (X) Returns the unary plus of a block sparse matrix X. Effectively the matrix itself, except signs of zeros.  File: linear-algebra.info, Node: Kronecker Products, Next: Circulant matrices, Prev: Block sparse matrices, Up: Function Reference 3.5 Kronecker Products ====================== 3.5.1 @kronprod/columns ----------------------- -- Function File: columns (KP) Return the number of columns in the Kronecker product KP. See also: @kronprod/rows, @kronprod/size, @kronprod/numel. 3.5.2 @kronprod/ctranspose -------------------------- -- Function File: ctranspose (KP) The complex conjugate transpose of a Kronecker product. This is equivalent to KP' See also: ctranspose, @kronprod/transpose. 3.5.3 @kronprod/det ------------------- -- Function File: det (KP) Compute the determinant of a Kronecker product. If KP is the Kronecker product of the N-by-N matrix A and the Q-by-Q matrix B, then the determinant is computed as det (A)^q * det (B)^n If KP is not a Kronecker product of square matrices the determinant is computed by forming the full matrix and then computing the determinant. See also: det, @kronprod/trace, @kronprod/rank, @kronprod/full. 3.5.4 @kronprod/disp -------------------- -- Function File: disp (KP) Show the content of the Kronecker product KP. To avoid evaluating the Kronecker product, this function displays the two matrices defining the product. To display the actual values of KP, use ‘disp (full (KP))’. This function is equivalent to ‘@kronprod/display’. See also: @kronprod/display, @kronprod/full. 3.5.5 @kronprod/display ----------------------- -- Function File: display (KP) Show the content of the Kronecker product KP. To avoid evaluating the Kronecker product, this function displays the two matrices defining the product. To display the actual values of KP, use ‘display (full (KP))’. See also: @kronprod/displ, @kronprod/full. 3.5.6 @kronprod/full -------------------- -- Function File: full (KP) Return the full matrix representation of the Kronecker product KP. If KP is the Kronecker product of an N-by-M matrix and a Q-by-R matrix, then the result is a NQ-by-MR matrix. Thus, the result can require vast amount of memory, so this function should be avoided whenever possible. See also: full, @kronprod/sparse. 3.5.7 @kronprod/inv ------------------- -- Function File: inv (KP) Return the inverse of the Kronecker product KP. If KP is the Kronecker product of two square matrices A and B, the inverse will be computed as the Kronecker product of the inverse of A and B. If KP is square but not a Kronecker product of square matrices, the inverse will be computed using the SVD See also: @kronprod/sparse. 3.5.8 @kronprod/iscomplex ------------------------- -- Function File: iscomplex (KP) Return true if the Kronecker product KP contains any complex values. See also: iscomplex, @kronprod/isreal. 3.5.9 @kronprod/ismatrix ------------------------ -- Function File: ismatrix (KP) Return true to indicate that the Kronecker product KP always is a matrix. 3.5.10 @kronprod/isreal ----------------------- -- Function File: isreal (KP) Return true if the Kronecker product KP is real, i.e. has no imaginary components. See also: isreal, @kronprod/iscomplex. 3.5.11 @kronprod/issparse ------------------------- -- Function File: issparse (KP) Return true if one of the matrices in the Kronecker product KP is sparse. See also: @kronprod/sparse. 3.5.12 @kronprod/issquare ------------------------- -- Function File: issquare (KP) Return true if the Kronecker product KP is a square matrix. See also: @kronprod/size. 3.5.13 @kronprod/kronprod ------------------------- -- Function File: kronprod (A, B) -- Function File: kronprod (A, B, P) Construct a Kronecker product object. XXX: Write proper documentation With two input arguments, the following matrix is represented: kron (A, B); With three input arguments, the following matrix is represented: P * kron (A, B) * P' (P must be a permutation matrix) 3.5.14 @kronprod/minus ---------------------- -- Function File: minus (A, A) Return the difference between a Kronecker product and another matrix. This is performed by forming the full matrix of both inputs and is as such a potential expensive operation. See also: minus, @kronprod/plus. 3.5.15 @kronprod/mldivide ------------------------- -- Function File: mldivide (M1, M2) Perform matrix left division. 3.5.16 @kronprod/mpower ----------------------- -- Function File: mpower (KP, K) Perform matrix power operation. 3.5.17 @kronprod/mtimes ----------------------- -- Function File: mtimes (KP1, KP2) Perform matrix multiplication operation. 3.5.18 @kronprod/numel ---------------------- -- Function File: numel (KP) Return the number of elements in the Kronecker product KP. See also: numel, @kronprod/rows, @kronprod/columns, @kronprod/size. 3.5.19 @kronprod/plus --------------------- -- Function File: plus (A, A) Return the sum of a Kronecker product and another matrix. This is performed by forming the full matrix of both inputs and is as such a potential expensive operation. See also: plus, @kronprod/minus. 3.5.20 @kronprod/rank --------------------- -- Function File: rank (KP) Return the rank of the Kronecker product KP. This is computed as the product of the ranks of the matrices forming the product. See also: rank, @kronprod/det, @kronprod/trace. 3.5.21 @kronprod/rdivide ------------------------ -- Function File: rdivide (A, B) Perform element-by-element right division. 3.5.22 @kronprod/rows --------------------- -- Function File: rows (KP) Return the number of rows in the Kronecker product KP. See also: rows, @kronprod/size, @kronprod/columns, @kronprod/numel. 3.5.23 @kronprod/size --------------------- -- Function File: size (KP) -- Function File: size (KP, DIM) Return the size of the Kronecker product KP as a vector. See also: size, @kronprod/rows, @kronprod/columns, @kronprod/numel. 3.5.24 @kronprod/size_equal --------------------------- -- Function File: size_equal (...) True if all input have same dimensions. 3.5.25 @kronprod/sparse ----------------------- -- Function File: sparse (KP) Return the Kronecker product KP represented as a sparse matrix. See also: sparse, @kronprod/issparse, @kronprod/full. 3.5.26 @kronprod/times ---------------------- -- Function File: times (KP, KP2) Perform elemtn-by-element multiplication. 3.5.27 @kronprod/trace ---------------------- -- Function File: trace (KP) Returns the trace of the Kronecker product KP. If KP is a Kronecker product of two square matrices, the trace is computed as the product of the trace of these two matrices. Otherwise the trace is computed by forming the full matrix. See also: @kronprod/det, @kronprod/rank, @kronprod/full. 3.5.28 @kronprod/transpose -------------------------- -- Function File: transpose (KP) Returns the transpose of the Kronecker product KP. This is equivalent to KP.' See also: transpose, @kronprod/ctranspose. 3.5.29 @kronprod/uminus ----------------------- -- Function File: uminus (KP) Returns the unary minus operator working on the Kronecker product KP. This corresponds to ‘-KP’ and simply returns the Kronecker product with the sign of the smallest matrix in the product reversed. See also: @kronprod/uminus. 3.5.30 @kronprod/uplus ---------------------- -- Function File: uplus (KP) Returns the unary plus operator working on the Kronecker product KP. This corresponds to ‘+KP’ and simply returns the Kronecker product unchanged. See also: @kronprod/uminus.  File: linear-algebra.info, Node: Circulant matrices, Prev: Kronecker Products, Up: Function Reference 3.6 Circulant matrices ====================== 3.6.1 circulant_eig ------------------- -- Function File: LAMBDA = circulant_eig (V) -- Function File: [VS, LAMBDA] = circulant_eig (V) Fast, compact calculation of eigenvalues and eigenvectors of a circulant matrix Given an N*1 vector V, return the eigenvalues LAMBDA and optionally eigenvectors VS of the N*N circulant matrix C that has V as its first column Theoretically same as ‘eig(make_circulant_matrix(v))’, but many fewer computations; does not form C explicitly Reference: Robert M. Gray, Toeplitz and Circulant Matrices: A Review, Now Publishers, http://ee.stanford.edu/~gray/toeplitz.pdf, Chapter 3 See also: gallery, circulant_matrix_vector_product, circulant_inv. 3.6.2 circulant_inv ------------------- -- Function File: C = circulant_inv (V) Fast, compact calculation of inverse of a circulant matrix Given an N*1 vector V, return the inverse C of the N*N circulant matrix C that has V as its first column The returned C is the first column of the inverse, which is also circulant - to get the full matrix, use 'circulant_make_matrix(c)' Theoretically same as ‘inv(make_circulant_matrix(v))(:, 1)’, but requires many fewer computations and does not form matrices explicitly Roundoff may induce a small imaginary component in C even if V is real - use ‘real(c)’ to remedy this Reference: Robert M. Gray, Toeplitz and Circulant Matrices: A Review, Now Publishers, http://ee.stanford.edu/~gray/toeplitz.pdf, Chapter 3 See also: gallery, circulant_matrix_vector_product, circulant_eig. 3.6.3 circulant_make_matrix --------------------------- -- Function File: C = circulant_make_matrix (V) Produce a full circulant matrix given the first column. _Note:_ this function has been deprecated and will be removed in the future. Instead, use ‘gallery’ with the the ‘circul’ option. To obtain the exactly same matrix, transpose the result, i.e., replace ‘circulant_make_matrix (V)’ with ‘gallery ("circul", V)'’. Given an N*1 vector V, returns the N*N circulant matrix C where V is the left column and all other columns are downshifted versions of V. Note: If the first row R of a circulant matrix is given, the first column V can be obtained as ‘v = r([1 end:-1:2])’. Reference: Gene H. Golub and Charles F. Van Loan, Matrix Computations, 3rd Ed., Section 4.7.7 See also: gallery, circulant_matrix_vector_product, circulant_eig, circulant_inv. 3.6.4 circulant_matrix_vector_product ------------------------------------- -- Function File: Y = circulant_matrix_vector_product (V, X) Fast, compact calculation of the product of a circulant matrix with a vector Given N*1 vectors V and X, return the matrix-vector product Y = CX, where C is the N*N circulant matrix that has V as its first column Theoretically the same as ‘make_circulant_matrix(x) * v’, but does not form C explicitly; uses the discrete Fourier transform Because of roundoff, the returned Y may have a small imaginary component even if V and X are real (use ‘real(y)’ to remedy this) Reference: Gene H. Golub and Charles F. Van Loan, Matrix Computations, 3rd Ed., Section 4.7.7 See also: gallery, circulant_eig, circulant_inv.  Tag Table: Node: Top238 Node: Overview1236 Node: Installing and loading1432 Node: Function Reference2598 Node: Vector functions2887 Node: Matrix functions3536 Node: Matrix factorization20010 Node: Block sparse matrices25123 Node: Kronecker Products29362 Node: Circulant matrices37373  End Tag Table  Local Variables: coding: utf-8 End: �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������linear-algebra-2.2.4/doc/PaxHeaders/linear-algebra.html���������������������������������������������0000644�0000000�0000000�00000000062�15146653315�017755� x����������������������������������������������������������������������������������������������������ustar�00�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������20 atime=1771787981 30 ctime=1771788142.228370636 ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������linear-algebra-2.2.4/doc/linear-algebra.html��������������������������������������������������������0000644�0001750�0001750�00000240000�15146653315�020265� 0����������������������������������������������������������������������������������������������������ustar�00philip��������������������������philip�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������<!DOCTYPE html> <html> <!-- Created by GNU Texinfo 7.2, https://www.gnu.org/software/texinfo/ --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Octave linear-algebra - linear-algebra package for GNU octave

Octave linear-algebra package

Copyright © The Octave Project Developers

Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.


1 Overview

The linear-algebra package contains additional linear algebra functions.


2 Installing and loading

The linear-algebra package must be installed and then loaded to be used.

It can be installed in GNU Octave directly from octave-forge,

2.1 Windows install

If running in Windows, the package may already be installed, to check run:

pkg list linear-algebra

2.2 Installing

With an internet connection available, the linear-algebra package can be installed from packages.octave.org using the following command within GNU Octave:

pkg install linear-algebra

The latest released version of the package will be downloaded and installed.

Otherwise, if the package file has already been downloaded it can be installed using the following command in GNU Octave:

pkg install linear-algebra-2.2.4.tar.gz

2.3 Loading

Regardless of the method of installing the package, in order to use its functions, the package must be loaded using the pkg load command:

pkg load linear-algebra

The package must be loaded on each GNU Octave session.


3 Function Reference


3.1 Vector functions

3.1.1 vec_projection

Function File: out = vec_projection (x, y)

Compute the vector projection of a 3-vector onto another. x : size 1 x 3 and y : size 1 x 3 tol : size 1 x 1

      vec_projection ([1,0,0], [0.5,0.5,0])
      ⇒ 0.7071

Vector projection of x onto y, both are 3-vectors, returning the value of x along y. Function uses dot product, Euclidean norm, and angle between vectors to compute the proper length along y.


3.2 Matrix functions

3.2.1 cartprod

Function File: cartprod (varargin)

Computes the cartesian product of given column vectors ( row vectors ). The vector elements are assumend to be numbers.

Alternatively the vectors can be specified by as a matrix, by its columns.

To calculate the cartesian product of vectors, P = A x B x C x D ... . Requires A, B, C, D be column vectors. The algorithm is iteratively calcualte the products, ( ( (A x B ) x C ) x D ) x etc.

   cartprod(1:2,3:4,0:1)
   ans =   1   3   0
           2   3   0
           1   4   0
           2   4   0
           1   3   1
           2   3   1
           1   4   1
           2   4   1

See also: kron.

3.2.2 cod

Function File: [q, r, z] = cod (a)
Function File: [q, r, z, p] = cod (a)
Function File: […] = cod (a, '0')

Computes the complete orthogonal decomposition (COD) of the matrix a:

   a = q*r*z'

Let a be an M-by-N matrix, and let K = min(M, N). Then q is M-by-M orthogonal, z is N-by-N orthogonal, and r is M-by-N such that r(:,1:K) is upper trapezoidal and r(:,K+1:N) is zero. The additional p output argument specifies that pivoting should be used in the first step (QR decomposition). In this case,

   a*p = q*r*z'

If a second argument of ’0’ is given, an economy-sized factorization is returned so that r is K-by-K.

NOTE: This is currently implemented by double QR factorization plus some tricky manipulations, and is not as efficient as using xRZTZF from LAPACK.

See also: qr.

3.2.3 funm

Function File: B = funm (A, F)

Compute matrix equivalent of function F; F can be a function name or a function handle and A must be a square matrix.

For trigonometric and hyperbolic functions, thfm is automatically invoked as that is based on expm and diagonalization is avoided. For other functions diagonalization is invoked, which implies that -depending on the properties of input matrix A- the results can be very inaccurate without any warning. For easy diagonizable and stable matrices the results of funm will be sufficiently accurate.

Note that you should not use funm for ’sqrt’, ’log’ or ’exp’; instead use sqrtm, logm and expm as these are more robust.

Examples:

   B = funm (A, sin);
   (Compute matrix equivalent of sin() )
   function bk1 = besselk1 (x)
      bk1 = besselk(1, x);
   endfunction
   B = funm (A, besselk1);
   (Compute matrix equivalent of bessel function K1();
    a helper function is needed here to convey extra
    arguments for besselk() )

Note that a much improved funm.m function has been implemented in Octave 11.1.0, so funm.m will be removed from the linear-algebra package if that is installed in Octave 11+.

See also: thfm, expm, logm, sqrtm.

3.2.4 lobpcg

Function File: [blockVectorX, lambda] = lobpcg (blockVectorX, operatorA)
Function File: [blockVectorX, lambda, failureFlag] = lobpcg (blockVectorX, operatorA)
Function File: [blockVectorX, lambda, failureFlag, lambdaHistory, residualNormsHistory] = lobpcg (blockVectorX, operatorA, operatorB, operatorT, blockVectorY, residualTolerance, maxIterations, verbosityLevel)

Solves Hermitian partial eigenproblems using preconditioning.

The first form outputs the array of algebraic smallest eigenvalues lambda and corresponding matrix of orthonormalized eigenvectors blockVectorX of the Hermitian (full or sparse) operator operatorA using input matrix blockVectorX as an initial guess, without preconditioning, somewhat similar to:

 # for real symmetric operator operatorA
 opts.issym  = 1; opts.isreal = 1; K = size (blockVectorX, 2);
 [blockVectorX, lambda] = eigs (operatorA, K, 'SR', opts);

 # for Hermitian operator operatorA
 K = size (blockVectorX, 2);
 [blockVectorX, lambda] = eigs (operatorA, K, 'SR');

The second form returns a convergence flag. If failureFlag is 0 then all the eigenvalues converged; otherwise not all converged.

The third form computes smallest eigenvalues lambda and corresponding eigenvectors blockVectorX of the generalized eigenproblem Ax=lambda Bx, where Hermitian operators operatorA and operatorB are given as functions, as well as a preconditioner, operatorT. The operators operatorB and operatorT must be in addition positive definite. To compute the largest eigenpairs of operatorA, simply apply the code to operatorA multiplied by -1. The code does not involve any matrix factorizations of operatorA and operatorB, thus, e.g., it preserves the sparsity and the structure of operatorA and operatorB.

residualTolerance and maxIterations control tolerance and max number of steps, and verbosityLevel = 0, 1, or 2 controls the amount of printed info. lambdaHistory is a matrix with all iterative lambdas, and residualNormsHistory are matrices of the history of 2-norms of residuals

Required input:

  • blockVectorX (class numeric) - initial approximation to eigenvectors, full or sparse matrix n-by-blockSize. blockVectorX must be full rank.
  • operatorA (class numeric, char, or function_handle) - the main operator of the eigenproblem, can be a matrix, a function name, or handle

Optional function input:

  • operatorB (class numeric, char, or function_handle) - the second operator, if solving a generalized eigenproblem, can be a matrix, a function name, or handle; by default if empty, operatorB = I.
  • operatorT (class char or function_handle) - the preconditioner, by default operatorT(blockVectorX) = blockVectorX.

Optional constraints input:

  • blockVectorY (class numeric) - a full or sparse n-by-sizeY matrix of constraints, where sizeY < n. blockVectorY must be full rank. The iterations will be performed in the (operatorB-) orthogonal complement of the column-space of blockVectorY.

Optional scalar input parameters:

  • residualTolerance (class numeric) - tolerance, by default, residualTolerance = n * sqrt (eps)
  • maxIterations - max number of iterations, by default, maxIterations = min (n, 20)
  • verbosityLevel - either 0 (no info), 1, or 2 (with pictures); by default, verbosityLevel = 0.

Required output:

  • blockVectorX and lambda (class numeric) both are computed blockSize eigenpairs, where blockSize = size (blockVectorX, 2) for the initial guess blockVectorX if it is full rank.

Optional output:

  • failureFlag (class integer) as described above.
  • lambdaHistory (class numeric) as described above.
  • residualNormsHistory (class numeric) as described above.

Functions operatorA(blockVectorX), operatorB(blockVectorX) and operatorT(blockVectorX) must support blockVectorX being a matrix, not just a column vector.

Every iteration involves one application of operatorA and operatorB, and one of operatorT.

Main memory requirements: 6 (9 if isempty(operatorB)=0) matrices of the same size as blockVectorX, 2 matrices of the same size as blockVectorY (if present), and two square matrices of the size 3*blockSize.

In all examples below, we use the Laplacian operator in a 20x20 square with the mesh size 1 which can be generated in MATLAB by running:

 A = delsq (numgrid ('S', 21));
 n = size (A, 1);

or in MATLAB and Octave by:

 [~,~,A] = laplacian ([19, 19]);
 n = size (A, 1);

Note that laplacian is a function of the specfun octave-forge package.

The following Example:

 [blockVectorX, lambda, failureFlag] = lobpcg (randn (n, 8), A, 1e-5, 50, 2);

attempts to compute 8 first eigenpairs without preconditioning, but not all eigenpairs converge after 50 steps, so failureFlag=1.

The next Example:

 blockVectorY = [];
 lambda_all = [];
 for j = 1:4
   [blockVectorX, lambda] = lobpcg (randn (n, 2), A, blockVectorY, 1e-5, 200, 2);
   blockVectorY           = [blockVectorY, blockVectorX];
   lambda_all             = [lambda_all' lambda']';
   pause;
 end

attemps to compute the same 8 eigenpairs by calling the code 4 times with blockSize=2 using orthogonalization to the previously founded eigenvectors.

The following Example:

 R       = ichol (A, struct('michol', 'on'));
 precfun = @(x)R\(R'\x);
 [blockVectorX, lambda, failureFlag] = lobpcg (randn (n, 8), A, [], @(x)precfun(x), 1e-5, 60, 2);

computes the same eigenpairs in less then 25 steps, so that failureFlag=0 using the preconditioner function precfun, defined inline. If precfun is defined as an octave function in a file, the function handle @(x)precfun(x) can be equivalently replaced by the function name precfun. Running:

 [blockVectorX, lambda, failureFlag] = lobpcg (randn (n, 8), A, speye (n), @(x)precfun(x), 1e-5, 50, 2);

produces similar answers, but is somewhat slower and needs more memory as technically a generalized eigenproblem with B=I is solved here.

The following example for a mostly diagonally dominant sparse matrix A demonstrates different types of preconditioning, compared to the standard use of the main diagonal of A:

 clear all; close all;
 n       = 1000;
 M       = spdiags ([1:n]', 0, n, n);
 precfun = @(x)M\x;
 A       = M + sprandsym (n, .1);
 Xini    = randn (n, 5);
 maxiter = 15;
 tol     = 1e-5;
 [~,~,~,~,rnp] = lobpcg (Xini, A, tol, maxiter, 1);
 [~,~,~,~,r]   = lobpcg (Xini, A, [], @(x)precfun(x), tol, maxiter, 1);
 subplot (2,2,1), semilogy (r'); hold on;
 semilogy (rnp', ':>');
 title ('No preconditioning (top)'); axis tight;
 M(1,2)  = 2;
 precfun = @(x)M\x; % M is no longer symmetric
 [~,~,~,~,rns] = lobpcg (Xini, A, [], @(x)precfun(x), tol, maxiter, 1);
 subplot (2,2,2), semilogy (r'); hold on;
 semilogy (rns', '--s');
 title ('Nonsymmetric preconditioning (square)'); axis tight;
 M(1,2)  = 0;
 precfun = @(x)M\(x+10*sin(x)); % nonlinear preconditioning
 [~,~,~,~,rnl] = lobpcg (Xini, A, [], @(x)precfun(x), tol, maxiter, 1);
 subplot (2,2,3),  semilogy (r'); hold on;
 semilogy (rnl', '-.*');
 title ('Nonlinear preconditioning (star)'); axis tight;
 M       = abs (M - 3.5 * speye (n, n));
 precfun = @(x)M\x;
 [~,~,~,~,rs] = lobpcg (Xini, A, [], @(x)precfun(x), tol, maxiter, 1);
 subplot (2,2,4),  semilogy (r'); hold on;
 semilogy (rs', '-d');
 title ('Selective preconditioning (diamond)'); axis tight;

References

This main function lobpcg is a version of the preconditioned conjugate gradient method (Algorithm 5.1) described in A. V. Knyazev, Toward the Optimal Preconditioned Eigensolver: Locally Optimal Block Preconditioned Conjugate Gradient Method, SIAM Journal on Scientific Computing 23 (2001), no. 2, pp. 517-541. http://dx.doi.org/10.1137/S1064827500366124

Known bugs/features

  • an excessively small requested tolerance may result in often restarts and instability. The code is not written to produce an eps-level accuracy! Use common sense.
  • the code may be very sensitive to the number of eigenpairs computed, if there is a cluster of eigenvalues not completely included, cf.
     operatorA = diag ([1 1.99 2:99]);
     [blockVectorX, lambda] = lobpcg (randn (100, 1),operatorA, 1e-10, 80, 2);
     [blockVectorX, lambda] = lobpcg (randn (100, 2),operatorA, 1e-10, 80, 2);
     [blockVectorX, lambda] = lobpcg (randn (100, 3),operatorA, 1e-10, 80, 2);
    

Distribution

The main distribution site: http://math.ucdenver.edu/~aknyazev/

A C-version of this code is a part of the http://code.google.com/p/blopex/ package and is directly available, e.g., in PETSc and HYPRE.

3.2.5 ndcovlt

Function File: y = ndcovlt (x, t1, t2, …)

Computes an n-dimensional covariant linear transform of an n-d tensor, given a transformation matrix for each dimension. The number of columns of each transformation matrix must match the corresponding extent of x, and the number of rows determines the corresponding extent of y. For example:

   size (x, 2) == columns (t2)
   size (y, 2) == rows (t2)

The element y(i1, i2, …) is defined as a sum of

   x(j1, j2, ...) * t1(i1, j1) * t2(i2, j2) * ...

over all j1, j2, …. For two dimensions, this reduces to

   y = t1 * x * t2.'

[] passed as a transformation matrix is converted to identity matrix for the corresponding dimension.

3.2.6 rotparams

Function File: [vstacked, astacked] = rotparams (rstacked)

The function w = rotparams (r) - Inverse to rotv(). Using, w = rotparams(r) is such that rotv(w)*r’ == eye(3).

If used as, [v,a]=rotparams(r) , idem, with v (1 x 3) s.t. w == a*v.

0 <= norm(w)==a <= pi

:-O !! Does not check if ’r’ is a rotation matrix.

Ignores matrices with zero rows or with NaNs. (returns 0 for them)

See also: rotv.

3.2.7 rotv

Function File: r = rotv ( v, ang )

The functionrotv calculates a Matrix of rotation about v w/ angle |v| r = rotv(v [,ang])

Returns the rotation matrix w/ axis v, and angle, in radians, norm(v) or ang (if present).

rotv(v) == w’*w + cos(a) * (eye(3)-w’*w) - sin(a) * crossmat(w)

where a = norm (v) and w = v/a.

v and ang may be vertically stacked : If ’v’ is 2x3, then rotv( v ) == [rotv(v(1,:)); rotv(v(2,:))]

See also: rotparams, rota, rot.

3.2.8 smwsolve

Function File: x = smwsolve (a, u, v, b)
Function File: smwsolve (solver, u, v, b)

Solves the square system (A + U*V')*X == B, where u and v are matrices with several columns, using the Sherman-Morrison-Woodbury formula, so that a system with a as left-hand side is actually solved. This is especially advantageous if a is diagonal, sparse, triangular or positive definite. a can be sparse or full, the other matrices are expected to be full. Instead of a matrix a, a user may alternatively provide a function solver that performs the left division operation.

3.2.9 thfm

Function File: y = thfm (x, mode)

Trigonometric/hyperbolic functions of square matrix x.

mode must be the name of a function. Valid functions are ’sin’, ’cos’, ’tan’, ’sec’, ’csc’, ’cot’ and all their inverses and/or hyperbolic variants, and ’sqrt’, ’log’ and ’exp’.

The code thfm (x, 'cos') calculates matrix cosinus even if input matrix x is not diagonalizable.

Important note: This algorithm does not use an eigensystem similarity transformation. It maps the mode functions to functions of expm, logm and sqrtm, which are known to be robust with respect to non-diagonalizable (’defective’) x.

See also: funm.


3.3 Matrix factorization

3.3.1 nmf_bpas

Function File: [W, H, iter, HIS] = nmf_bpas (A, k)

Nonnegative Matrix Factorization by Alternating Nonnegativity Constrained Least Squares using Block Principal Pivoting/Active Set method.

This function solves one the following problems: given A and k, find W and H such that

(1) minimize 1/2 * || A-WH ||_F^2

(2) minimize 1/2 * ( || A-WH ||_F^2 + alpha * || W ||_F^2 + beta * || H ||_F^2 )

(3) minimize 1/2 * ( || A-WH ||_F^2 + alpha * || W ||_F^2 + beta * (sum_(i=1)^n || H(:,i) ||_1^2 ) )

where W>=0 and H>=0 elementwise. The input arguments are A : Input data matrix (m x n) and k : Target low-rank.

Optional Inputs

Type

Default is ’regularized’, which is recommended for quick application testing unless ’sparse’ or ’plain’ is explicitly needed. If sparsity is needed for ’W’ factor, then apply this function for the transpose of ’A’ with formulation (3). Then, exchange ’W’ and ’H’ and obtain the transpose of them. Imposing sparsity for both factors is not recommended and thus not included in this software.

’plain’

to use formulation (1)

’regularized’

to use formulation (2)

’sparse’

to use formulation (3)

NNLSSolver

Default is ’bp’, which is in general faster.

’bp’

to use the algorithm in [1]

’as’

to use the algorithm in [2]

Alpha

Parameter alpha in the formulation (2) or (3). Default is the average of all elements in A. No good justfication for this default value, and you might want to try other values.

Beta

Parameter beta in the formulation (2) or (3). Default is the average of all elements in A. No good justfication for this default value, and you might want to try other values.

MaxIter

Maximum number of iterations. Default is 100.

MinIter

Minimum number of iterations. Default is 20.

MaxTime

Maximum amount of time in seconds. Default is 100,000.

Winit

(m x k) initial value for W.

Hinit

(k x n) initial value for H.

Tol

Stopping tolerance. Default is 1e-3. If you want to obtain a more accurate solution, decrease TOL and increase MAX_ITER at the same time.

Verbose

If present the function will show information during the calculations.

Outputs

W

Obtained basis matrix (m x k)

H

Obtained coefficients matrix (k x n)

iter

Number of iterations

HIS

If present the history of computation is returned.

Usage Examples:

  nmf_bpas (A,10)
  nmf_bpas (A,20,'verbose')
  nmf_bpas (A,30,'verbose','nnlssolver','as')
  nmf_bpas (A,5,'verbose','type','sparse')
  nmf_bpas (A,60,'verbose','type','plain','Winit',rand(size(A,1),60))
  nmf_bpas (A,70,'verbose','type','sparse','nnlssolver','bp','alpha',1.1,'beta',1.3)

References: [1] For using this software, please cite:
Jingu Kim and Haesun Park, Toward Faster Nonnegative Matrix Factorization: A New Algorithm and Comparisons,
In Proceedings of the 2008 Eighth IEEE International Conference on Data Mining (ICDM’08), 353-362, 2008
[2] If you use ’nnls_solver’=’as’ (see below), please cite:
Hyunsoo Kim and Haesun Park, Nonnegative Matrix Factorization Based
on Alternating Nonnegativity Constrained Least Squares and Active Set Method,
SIAM Journal on Matrix Analysis and Applications, 2008, 30, 713-730

Check original code at http://www.cc.gatech.edu/~jingu

See also: nmf_pg.

3.3.2 nmf_pg

Function File: [W, H] = nmf_pg (V, Winit, Hinit, tol, timelimit, maxiter)

Non-negative matrix factorization by alternative non-negative least squares using projected gradients.

The matrix V is factorized into two possitive matrices W and H such that V = W*H + U. Where U is a matrix of residuals that can be negative or positive. When the matrix V is positive the order of the elements in U is bounded by the optional named argument tol (default value 1e-9).

The factorization is not unique and depends on the inital guess for the matrices W and H. You can pass this initalizations using the optional named arguments Winit and Hinit.

timelimit, maxiter: limit of time and iterations

Examples:

   A     = rand(10,5);
   [W H] = nmf_pg(A,tol=1e-3);
   U     = W*H -A;
   disp(max(abs(U)));

3.4 Block sparse matrices

3.4.1 @blksparse/blksize

Function File: blksize (x)

Returns the block size of the matrix.

3.4.2 @blksparse/blksparse

Function File: s = blksparse (i, j, sv)
Function File: s = blksparse (i, j, sv, m, n)
Function File: s = blksparse (…, mode)

Construct a block sparse matrix. The meaning of arguments is analogous to the built-in sparse function, except that i, j are indices of blocks rather than elements, and sv is a 3-dimensional array, the first two dimensions determining the block size. Optionally, m and n can be specified as the true block dimensions; if not, the maximum values of i, j are taken instead. The resulting sparse matrix has the size

   [m*p, n*q]

where

   p = size (sv, 1)
   q = size (sv, 2)

The blocks are located so that

s(i(k):i(k)+p-1, j(k):j(K)+q-1) = sv(:,:,k)

Multiple blocks corresponding to the same pair of indices are summed, unless mode is "unique", in which case the last of them is used.

3.4.3 @blksparse/ctranspose

Function File: ctranspose (x)

Returns the conjugate transpose of a block sparse matrix x.

3.4.4 @blksparse/display

Function File: display (x)

Displays the block sparse matrix.

3.4.5 @blksparse/full

Function File: full (x)

Converts a block sparse matrix to full.

3.4.6 @blksparse/ismatrix

Function File: ismatrix (s)

Returns true (a blksparse object is a matrix).

3.4.7 @blksparse/isreal

Function File: isreal (s)

Returns true if the array is non-complex.

3.4.8 @blksparse/issparse

Function File: issparse (s)

Returns true since a blksparse is sparse by definition.

3.4.9 @blksparse/minus

Function File: minus (s1, s2)

Subtract two blksparse objects.

3.4.10 @blksparse/mldivide

Function File: mldivide (x, y)

Performs a left division with a block sparse matrix. If x is a block sparse matrix, it must be either diagonal or triangular, and y must be full. If x is built-in sparse or full, y is converted accordingly, then the built-in division is used.

3.4.11 @blksparse/mrdivide

Function File: mrdivide (x, y)

Performs a left division with a block sparse matrix. If y is a block sparse matrix, it must be either diagonal or triangular, and x must be full. If y is built-in sparse or full, x is converted accordingly, then the built-in division is used.

3.4.12 @blksparse/mtimes

Function File: mtimes (x, y)

Multiplies a block sparse matrix with a full matrix, or two block sparse matrices. Multiplication of block sparse * sparse is not implemented. If one of arguments is a scalar, it’s a scalar multiply.

3.4.13 @blksparse/plus

Function File: plus (s1, s2)

Add two blksparse objects.

3.4.14 @blksparse/size

Function File: size (x)

Returns the size of the matrix.

3.4.15 @blksparse/sparse

Function File: sparse (x)

Converts a block sparse matrix to (built-in) sparse.

3.4.16 @blksparse/subsref

Function File: subsref (s, subs)

Index elements from a blksparse object.

3.4.17 @blksparse/transpose

Function File: transpose (x)

Returns the transpose of a block sparse matrix x.

3.4.18 @blksparse/uminus

Function File: uminus (x)

Returns the negative of a block sparse matrix x.

3.4.19 @blksparse/uplus

Function File: uplus (x)

Returns the unary plus of a block sparse matrix x. Effectively the matrix itself, except signs of zeros.


3.5 Kronecker Products

3.5.1 @kronprod/columns

Function File: columns (KP)

Return the number of columns in the Kronecker product KP.

See also: @kronprod/rows, @kronprod/size, @kronprod/numel.

3.5.2 @kronprod/ctranspose

Function File: ctranspose (KP)

The complex conjugate transpose of a Kronecker product. This is equivalent to

KP'

See also: ctranspose, @kronprod/transpose.

3.5.3 @kronprod/det

Function File: det (KP)

Compute the determinant of a Kronecker product.

If KP is the Kronecker product of the n-by-n matrix A and the q-by-q matrix B, then the determinant is computed as

 det (A)^q * det (B)^n

If KP is not a Kronecker product of square matrices the determinant is computed by forming the full matrix and then computing the determinant.

See also: det, @kronprod/trace, @kronprod/rank, @kronprod/full.

3.5.4 @kronprod/disp

Function File: disp (KP)

Show the content of the Kronecker product KP. To avoid evaluating the Kronecker product, this function displays the two matrices defining the product. To display the actual values of KP, use disp (full (KP)).

This function is equivalent to @kronprod/display.

See also: @kronprod/display, @kronprod/full.

3.5.5 @kronprod/display

Function File: display (KP)

Show the content of the Kronecker product KP. To avoid evaluating the Kronecker product, this function displays the two matrices defining the product. To display the actual values of KP, use display (full (KP)).

See also: @kronprod/displ, @kronprod/full.

3.5.6 @kronprod/full

Function File: full (KP)

Return the full matrix representation of the Kronecker product KP.

If KP is the Kronecker product of an n-by-m matrix and a q-by-r matrix, then the result is a nq-by-mr matrix. Thus, the result can require vast amount of memory, so this function should be avoided whenever possible.

See also: full, @kronprod/sparse.

3.5.7 @kronprod/inv

Function File: inv (KP)

Return the inverse of the Kronecker product KP.

If KP is the Kronecker product of two square matrices A and B, the inverse will be computed as the Kronecker product of the inverse of A and B.

If KP is square but not a Kronecker product of square matrices, the inverse will be computed using the SVD

See also: @kronprod/sparse.

3.5.8 @kronprod/iscomplex

Function File: iscomplex (KP)

Return true if the Kronecker product KP contains any complex values.

See also: iscomplex, @kronprod/isreal.

3.5.9 @kronprod/ismatrix

Function File: ismatrix (KP)

Return true to indicate that the Kronecker product KP always is a matrix.

3.5.10 @kronprod/isreal

Function File: isreal (KP)

Return true if the Kronecker product KP is real, i.e. has no imaginary components.

See also: isreal, @kronprod/iscomplex.

3.5.11 @kronprod/issparse

Function File: issparse (KP)

Return true if one of the matrices in the Kronecker product KP is sparse.

See also: @kronprod/sparse.

3.5.12 @kronprod/issquare

Function File: issquare (KP)

Return true if the Kronecker product KP is a square matrix.

See also: @kronprod/size.

3.5.13 @kronprod/kronprod

Function File: kronprod (A, B)
Function File: kronprod (A, B, P)

Construct a Kronecker product object. XXX: Write proper documentation

With two input arguments, the following matrix is represented: kron (A, B);

With three input arguments, the following matrix is represented: P * kron (A, B) * P’ (P must be a permutation matrix)

3.5.14 @kronprod/minus

Function File: minus (a, a)

Return the difference between a Kronecker product and another matrix. This is performed by forming the full matrix of both inputs and is as such a potential expensive operation.

See also: minus, @kronprod/plus.

3.5.15 @kronprod/mldivide

Function File: mldivide (M1, M2)

Perform matrix left division.

3.5.16 @kronprod/mpower

Function File: mpower (KP, k)

Perform matrix power operation.

3.5.17 @kronprod/mtimes

Function File: mtimes (KP1, KP2)

Perform matrix multiplication operation.

3.5.18 @kronprod/numel

Function File: numel (KP)

Return the number of elements in the Kronecker product KP.

See also: numel, @kronprod/rows, @kronprod/columns, @kronprod/size.

3.5.19 @kronprod/plus

Function File: plus (a, a)

Return the sum of a Kronecker product and another matrix. This is performed by forming the full matrix of both inputs and is as such a potential expensive operation.

See also: plus, @kronprod/minus.

3.5.20 @kronprod/rank

Function File: rank (KP)

Return the rank of the Kronecker product KP. This is computed as the product of the ranks of the matrices forming the product.

See also: rank, @kronprod/det, @kronprod/trace.

3.5.21 @kronprod/rdivide

Function File: rdivide (a, b)

Perform element-by-element right division.

3.5.22 @kronprod/rows

Function File: rows (KP)

Return the number of rows in the Kronecker product KP.

See also: rows, @kronprod/size, @kronprod/columns, @kronprod/numel.

3.5.23 @kronprod/size

Function File: size (KP)
Function File: size (KP, dim)

Return the size of the Kronecker product KP as a vector.

See also: size, @kronprod/rows, @kronprod/columns, @kronprod/numel.

3.5.24 @kronprod/size_equal

Function File: size_equal (…)

True if all input have same dimensions.

3.5.25 @kronprod/sparse

Function File: sparse (KP)

Return the Kronecker product KP represented as a sparse matrix.

See also: sparse, @kronprod/issparse, @kronprod/full.

3.5.26 @kronprod/times

Function File: times (KP, KP2)

Perform elemtn-by-element multiplication.

3.5.27 @kronprod/trace

Function File: trace (KP)

Returns the trace of the Kronecker product KP.

If KP is a Kronecker product of two square matrices, the trace is computed as the product of the trace of these two matrices. Otherwise the trace is computed by forming the full matrix.

See also: @kronprod/det, @kronprod/rank, @kronprod/full.

3.5.28 @kronprod/transpose

Function File: transpose (KP)

Returns the transpose of the Kronecker product KP. This is equivalent to

KP.'

See also: transpose, @kronprod/ctranspose.

3.5.29 @kronprod/uminus

Function File: uminus (KP)

Returns the unary minus operator working on the Kronecker product KP. This corresponds to -KP and simply returns the Kronecker product with the sign of the smallest matrix in the product reversed.

See also: @kronprod/uminus.

3.5.30 @kronprod/uplus

Function File: uplus (KP)

Returns the unary plus operator working on the Kronecker product KP. This corresponds to +KP and simply returns the Kronecker product unchanged.

See also: @kronprod/uminus.


3.6 Circulant matrices

3.6.1 circulant_eig

Function File: lambda = circulant_eig (v)
Function File: [vs, lambda] = circulant_eig (v)

Fast, compact calculation of eigenvalues and eigenvectors of a circulant matrix
Given an n*1 vector v, return the eigenvalues lambda and optionally eigenvectors vs of the n*n circulant matrix C that has v as its first column

Theoretically same as eig(make_circulant_matrix(v)), but many fewer computations; does not form C explicitly

Reference: Robert M. Gray, Toeplitz and Circulant Matrices: A Review, Now Publishers, http://ee.stanford.edu/~gray/toeplitz.pdf, Chapter 3

See also: gallery, circulant_matrix_vector_product, circulant_inv.

3.6.2 circulant_inv

Function File: c = circulant_inv (v)

Fast, compact calculation of inverse of a circulant matrix
Given an n*1 vector v, return the inverse c of the n*n circulant matrix C that has v as its first column The returned c is the first column of the inverse, which is also circulant – to get the full matrix, use ‘circulant_make_matrix(c)’

Theoretically same as inv(make_circulant_matrix(v))(:, 1), but requires many fewer computations and does not form matrices explicitly

Roundoff may induce a small imaginary component in c even if v is real – use real(c) to remedy this

Reference: Robert M. Gray, Toeplitz and Circulant Matrices: A Review, Now Publishers, http://ee.stanford.edu/~gray/toeplitz.pdf, Chapter 3

See also: gallery, circulant_matrix_vector_product, circulant_eig.

3.6.3 circulant_make_matrix

Function File: C = circulant_make_matrix (v)

Produce a full circulant matrix given the first column.

Note: this function has been deprecated and will be removed in the future. Instead, use gallery with the the circul option. To obtain the exactly same matrix, transpose the result, i.e., replace circulant_make_matrix (v) with gallery ("circul", v)'.

Given an n*1 vector v, returns the n*n circulant matrix C where v is the left column and all other columns are downshifted versions of v.

Note: If the first row r of a circulant matrix is given, the first column v can be obtained as v = r([1 end:-1:2]).

Reference: Gene H. Golub and Charles F. Van Loan, Matrix Computations, 3rd Ed., Section 4.7.7

See also: gallery, circulant_matrix_vector_product, circulant_eig, circulant_inv.

3.6.4 circulant_matrix_vector_product

Function File: y = circulant_matrix_vector_product (v, x)

Fast, compact calculation of the product of a circulant matrix with a vector
Given n*1 vectors v and x, return the matrix-vector product y = Cx, where C is the n*n circulant matrix that has v as its first column

Theoretically the same as make_circulant_matrix(x) * v, but does not form C explicitly; uses the discrete Fourier transform

Because of roundoff, the returned y may have a small imaginary component even if v and x are real (use real(y) to remedy this)

Reference: Gene H. Golub and Charles F. Van Loan, Matrix Computations, 3rd Ed., Section 4.7.7

See also: gallery, circulant_eig, circulant_inv.

linear-algebra-2.2.4/doc/PaxHeaders/mkfuncdocs.py0000644000000000000000000000006215146653315016730 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/doc/mkfuncdocs.py0000755000175000017500000002766115146653315017263 0ustar00philipphilip#!/usr/bin/python3 ## Copyright 2018-2026 John Donoghue ## ## This program is free software: you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see ## . ## mkfuncdocs v1.0.8 ## mkfuncdocs.py will attempt to extract the help texts from functions in src ## dirs, extracting only those that are in the specifed INDEX file and output them ## to stdout in texi format ## ## It will extract from both .m and the help text for DEFUN_DLD help in .cc/.cpp ## files. ## ## It attempts to find the help text for each function in a file within the src search ## folders that match in order: [ functionname.m functionname.cc functionname.cpp ## functionname_withoutprefix.cc functionname_withoutprefix.cpp ] ## ## Usage: ## mkfundocs.py options INDEXfile ## Options can be 0 or more of: ## --verbose : Turn on verbose mode ## --src-dir=xxxxx : Add dir xxxxx to the dirs searched for the function file. ## If no directories are provided, it will default to looking in the ## 'inst' directory. ## --ignore=xxxxx : dont attempt to generate help for function xxxxx. ## --funcprefix=xxxxx : remove xxxxx from the function name when searching for matching ## source file. ## --allowscan : if can not find function, attemp to scan .cc,cpp,cxx files for match ## ## --standalone : generate a texinfo file expected to be used with being included in ## another document file. import sys import os import re import tempfile import shutil import fnmatch import subprocess import glob import calendar; import time; class Group: name = "Functions" functions = [] def __init__ (self, name=""): if name: self.name = name self.functions = [] class Index: name = "" groups = [] def texify_line(line): # convert any special chars in a line to texinfo format # currently just used for group formatting ? line = line.replace("@", "@@") line = line.replace("{", "@{") line = line.replace("}", "@}") line = line.replace(",", "@comma{}") return line def find_defun_line_in_file(filename, fnname): linecnt = 0 defun_line=re.compile(r"^DEFUN_DLD\s*\(\s*{}".format(fnname)) with open(filename, 'rt') as f: for line in f: if re.match(defun_line, line): return linecnt linecnt = linecnt + 1 return -1 def find_function_line_in_file(filename, fnname): linecnt = 0 func = False defun_line=re.compile(r"^\s*function \s*") with open(filename, 'rt') as f: for line in f: if func == True: x = line.strip() if x.startswith("## -*- texinfo -*-"): return linecnt else: func = False if re.match(defun_line, line): if line.find("=") != -1: x = line.split("=") x = x[-1] else: x = line.replace("function ", "") x = x.split("(") x = x[0].strip() if x == fnname: func = True linecnt = linecnt + 1 return -1 def read_m_file(filename, skip=0): help = [] inhelp = False havehelp = False; with open(filename, 'rt') as f: for line in f: line = line.lstrip() if skip > 0: skip = skip - 1 elif not havehelp: if havehelp == False and inhelp == False and line.startswith('##'): if "texinfo" in line: inhelp = True elif inhelp == True: if not line.startswith('##'): inhelp = False havehelp = True else: if line.startswith("## @"): line = line[3:] else: line = line[2:] help.append (line.rstrip()); return help def read_cc_file(filename, skip=0): help = [] inhelp = False havehelp = False; with open(filename, 'rt') as f: for line in f: line = line.lstrip() if skip > 0: skip = skip - 1 elif not havehelp: if havehelp == False and inhelp == False: if "texinfo" in line: inhelp = True elif inhelp == True: line = line.rstrip() if len(line) > 0 and line[-1] == '\\': line = line[:-1] line = line.rstrip() line = line.replace("\\n", "\n") line = line.replace("\\\"", "\"") if len(line) > 0 and line[-1] == '\n': line = line[:-1] # endif a texinfo line elif line.endswith('")'): line = line[:-2] if line.startswith('{'): inhelp = False havehelp = True else: help.append (line); return help def read_help (filename, skip=0): help = [] if filename[-2:] == ".m": help = read_m_file(filename, skip) else: help = read_cc_file(filename, skip) return help def read_index (filename, ignore): index = Index () with open(filename, 'rt') as f: lines = f.read().splitlines() #print ("read", lines) first = True category = Group() for l in lines: if l.startswith("#"): pass elif first: index.name = l; first = False elif l.startswith(" "): l = l.strip() # may be multiple functions here funcs = l.split() for f in funcs: if f not in ignore: category.functions.append(f); else: # new category name if len(category.functions) > 0: index.groups.append(category) category = Group(l.strip()) # left over category ? if len(category.functions) > 0: index.groups.append(category) return index; def find_class_file(fname, paths): for f in paths: # class constructor ? name = f + "/@" + fname + "/" + fname + ".m" if os.path.isfile(name): return name, 0 # perhaps classname.func format ? x = fname.split(".") if len(x) > 0: zname = x.pop() cname = ".".join(x) name = f + "/" + cname + ".m" if os.path.isfile(name): idx = find_function_line_in_file(name, zname) if idx >= 0: return name, idx name = f + "/@" + cname + "/" + zname + ".m" if os.path.isfile(name): return name, 0 return None, -1 def find_func_file(fname, paths, prefix, scanfiles=False): for f in paths: name = f + "/" + fname + ".m" if os.path.isfile(name): return name, 0 # class constructor ? name = f + "/@" + fname + "/" + fname + ".m" if os.path.isfile(name): return name, 0 name = f + "/" + fname + ".cc" if os.path.isfile(name): return name, 0 name = f + "/" + fname + ".cpp" if os.path.isfile(name): return name, 0 # if have a prefix, remove and try if prefix and fname.startswith(prefix): fname = fname[len(prefix):] name = f + "/" + fname + ".cc" if os.path.isfile(name): return name, 0 name = f + "/" + fname + ".cpp" if os.path.isfile(name): return name, 0 # if here, we still dont have a file match # if allowed to scan files, do that if scanfiles: #sys.stderr.write("Warning: Scaning for {}\n".format(fname)) for f in paths: files = list(f + "/" + a for a in os.listdir(f)) cc_files = fnmatch.filter(files, "*.cc") cpp_files = fnmatch.filter(files, "*.cpp") cxx_files = fnmatch.filter(files, "*.cxx") for fn in cc_files + cpp_files + cxx_files: line = find_defun_line_in_file(fn, fname) if line >= 0: #sys.stderr.write("Warning: Found function for {} in {} at {}\n".format(fname, fn, line)) return fn, line return None, -1 def display_standalone_header(): # make a file that doesnt need to be included in a texinfo file to # be valid print("@c mkfuncdocs output for a standalone function list") print("@include macros.texi") print("@ifnottex") print("@node Top") print("@top Function Documentation") print("Function documentation extracted from texinfo source in octave source files.") print("@contents") print("@end ifnottex") print("@node Function Reference") print("@chapter Function Reference") print("@cindex Function Reference") def display_standalone_footer(): print("@bye") def display_func(name, ref, help): print ("@c -----------------------------------------") print ("@subsection {}".format(name)) print ("@cindex {}".format(ref)) for l in help: print ("{}".format(l)) def process (args): options = { "verbose": False, "srcdir": [], "funcprefix": "", "ignore": [], "standalone": False, "allowscan": False } indexfile = "" for a in args: #print ("{}".format(a)) c=a.split("=") key=c[0] if len(c) > 1: val=c[1] else: val="" if key == "--verbose": options["verbose"] = True; if key == "--standalone": options["standalone"] = True; elif key == "--allowscan": options["allowscan"] = True; elif key == "--src-dir": if val: options["srcdir"].append(val); elif key == "--ignore": if val: options["ignore"].append(val); elif key == "--func-prefix": if val: options["funcprefix"] = val; elif val == "": if indexfile == "": indexfile = key if indexfile == "": raise Exception("No index filename") if len(options["srcdir"]) == 0: options["srcdir"].append("inst") #print "options=", options if options['standalone']: display_standalone_header() idx = read_index(indexfile, options["ignore"]) for g in idx.groups: #print ("************ {}".format(g.name)) g_name = texify_line(g.name) print ("@c ---------------------------------------------------") print ("@node {}".format(g_name)) print ("@section {}".format(g_name)) print ("@cindex {}".format(g_name)) for f in sorted(g.functions): print ("@c {} {}".format(g_name, f)) h = "" filename = "" path = "" if "@" in f: #print ("class func") path = f name = "@" + f ref = f.split("/")[-1] filename, lineno = find_func_file(path, options["srcdir"], options["funcprefix"]) elif "." in f: path = f ref = f.split(".")[-1] name = f.split(".")[-1] filename, lineno = find_class_file(path, options["srcdir"]) if not filename: parts = f.split('.') cnt = 0 path = "" for p in parts: if cnt < len(parts)-1: path = path + "/+" else: path = path + "/" path = path + p cnt = cnt + 1 name = f; ref = parts[-1] filename, lineno = find_func_file(path, options["srcdir"], options["funcprefix"]) elif "/" in f: path = f name = f ref = f.split("/")[-1] filename, lineno = find_func_file(path, options["srcdir"], options["funcprefix"]) else: path = f name = f ref = f filename, lineno = find_func_file(path, options["srcdir"], options["funcprefix"], options['allowscan']) if not filename: sys.stderr.write("Warning: Cant find source file for {}\n".format(f)) else: h = read_help (filename, lineno) if h: display_func (name, ref, h) if options['standalone']: display_standalone_footer() def show_usage(): print (sys.argv[0], "[options] indexfile") if __name__ == "__main__": if len(sys.argv) > 1: status = process(sys.argv[1:]) sys.exit(status) else: show_usage() linear-algebra-2.2.4/PaxHeaders/INDEX0000644000000000000000000000006215146653315014247 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/INDEX0000644000175000017500000000247715146653315014575 0ustar00philipphiliplinear-algebra >> Additional linear algebra functions Vector functions vec_projection Matrix functions cartprod cod funm lobpcg ndcovlt rotparams rotv smwsolve thfm Matrix factorization nmf_bpas nmf_pg Block sparse matrices @blksparse/blksparse @blksparse/blksize @blksparse/ctranspose @blksparse/display @blksparse/full @blksparse/ismatrix @blksparse/isreal @blksparse/issparse @blksparse/minus @blksparse/mldivide @blksparse/mrdivide @blksparse/mtimes @blksparse/plus @blksparse/size @blksparse/sparse @blksparse/subsref @blksparse/transpose @blksparse/uminus @blksparse/uplus Kronecker Products @kronprod/kronprod @kronprod/columns @kronprod/ctranspose @kronprod/det @kronprod/disp @kronprod/display @kronprod/full @kronprod/inv @kronprod/iscomplex @kronprod/ismatrix @kronprod/isreal @kronprod/issparse @kronprod/issquare @kronprod/minus @kronprod/mldivide @kronprod/mpower @kronprod/mtimes @kronprod/numel @kronprod/plus @kronprod/rank @kronprod/rdivide @kronprod/rows @kronprod/size @kronprod/size_equal @kronprod/sparse @kronprod/times @kronprod/trace @kronprod/transpose @kronprod/uminus @kronprod/uplus Circulant matrices circulant_make_matrix circulant_matrix_vector_product circulant_eig circulant_inv linear-algebra-2.2.4/PaxHeaders/post_install.m0000644000000000000000000000006215146653315016346 xustar0020 atime=1771787981 30 ctime=1771788142.228370636 linear-algebra-2.2.4/post_install.m0000644000175000017500000000277115146653315016671 0ustar00philipphilip## Copyright (C) 2026 Philip Nienhuis ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {} {@var{retval} =} post_install (@var{desc}) ## ## @seealso{} ## @end deftypefn function retval = post_install (desc) retval = 0; ## Remove funm.m for Octave >= 11.1.0 file_to_be_deleted = "funm.m"; if (compare_versions (ver ("octave").Version, "11.1.0", ">=")) nam = [desc.dir filesep file_to_be_deleted]; [st, msg] = unlink (nam); if (st < 0) warning ("pkg: couldn't delete file '%s'\n%s\n", nam, msg); else ## Also remove from INDEX fid = fopen ([desc.dir filesep "packinfo" filesep "INDEX"], "r"); txt = fread (fid, Inf, "*char")'; fclose (fid); txt = regexprep (txt, '\W*funm', ""); fid = fopen ([desc.dir filesep "packinfo" filesep "INDEX"], "w"); fprintf (fid, "%s", txt); fclose (fid); endif endif endfunction