Computes the squared Frobenius norm of X function Xnormfro = cnormsqfro(X) Returns the squared Frobenius norm of X. This function can be seen as norm(...,'fro')^2 but is compatible with dlarrays and structs with fields real and imag. Supports both real and complex numbers. See also: manoptADhelp
0001 function Xnormfro = cnormsqfro(X) 0002 % Computes the squared Frobenius norm of X 0003 % 0004 % function Xnormfro = cnormsqfro(X) 0005 % 0006 % Returns the squared Frobenius norm of X. This function can be seen as 0007 % norm(...,'fro')^2 but is compatible with dlarrays and structs with fields 0008 % real and imag. Supports both real and complex numbers. 0009 % 0010 % See also: manoptADhelp 0011 0012 % This file is part of Manopt: www.manopt.org. 0013 % Original author: Xiaowen Jiang, July. 31, 2021. 0014 % Contributors: Nicolas Boumal 0015 % Change log: 0016 0017 if iscstruct(X) 0018 Xnormfro = cinnerprodgeneral(X, X); 0019 0020 elseif isnumeric(X) 0021 if isreal(X) 0022 Xnormfro = X(:)'*X(:); 0023 else 0024 Xnormfro = sum(real(conj(X(:)).*X(:))); 0025 end 0026 0027 else 0028 ME = MException('cnormsqfro:inputError', ... 0029 'Input does not have the expected format.'); 0030 throw(ME); 0031 end 0032 0033 end