


PACKRFP assumes a symmetric matrix on input and returns its 'N','L' RFP (rectangular full packed) representation, i.e., a vector of length n*(n+1)/2 with appropriately mapped dense A matrix


0001 function [Arf] = packrfp(A) 0002 % PACKRFP assumes a symmetric matrix on input and returns its 'N','L' RFP 0003 % (rectangular full packed) representation, i.e., a vector of length 0004 % n*(n+1)/2 with appropriately mapped dense A matrix 0005 0006 % This file is a part of PENLAB package distributed under GPLv3 license 0007 % Copyright (c) 2013 by J. Fiala, M. Kocvara, M. Stingl 0008 % Last Modified: 27 Nov 2013 0009 0010 [n m] = size(A); 0011 if (n~=m) 0012 error('Input matrix needs to be square.') 0013 end 0014 0015 if (mod(n,2)==0) 0016 % n even, q=n/2, lda=n+1 0017 q=n/2; 0018 Atemp=zeros(n+1,q); 0019 Atemp(2:n+1,1:q) = tril(A(1:n,1:q)); 0020 Atemp(1:q,1:q) = Atemp(1:q,1:q) + tril(A(q+1:n,q+1:n))'; 0021 else 0022 % n odd, q=(n+1)/2, lda=n 0023 q=(n+1)/2; 0024 Atemp=zeros(n,q); 0025 Atemp(1:n,1:q) = tril(A(1:n,1:q)); 0026 Atemp(1:q-1,2:q) = Atemp(1:q-1,2:q) + tril(A(q+1:n,q+1:n))'; 0027 end 0028 0029 Arf = Atemp(:); 0030