Home > manopt > autodiff > functions_AD > cplus.m

cplus

PURPOSE ^

Computes the sum of A and B

SYNOPSIS ^

function plusAB = cplus(A,B)

DESCRIPTION ^

 Computes the sum of A and B

 function plusAB = cplus(A,B)

 Returns the sum of A and B. This function can be seen as A+B but is
 compatible with dlarrays and structs with fields real and imag.

 See also: manoptADhelp

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function plusAB = cplus(A,B)
0002 % Computes the sum of A and B
0003 %
0004 % function plusAB = cplus(A,B)
0005 %
0006 % Returns the sum of A and B. This function can be seen as A+B but is
0007 % compatible with dlarrays and structs with fields real and imag.
0008 %
0009 % See also: manoptADhelp
0010 
0011 % This file is part of Manopt: www.manopt.org.
0012 % Original author: Xiaowen Jiang, July. 31, 2021.
0013 % Contributors: Nicolas Boumal
0014 % Change log:
0015 
0016     if isnumeric(A) && iscstruct(B)
0017         realA = real(A);
0018         imagA = imag(A);
0019         plusAB.real = realA + B.real;
0020         plusAB.imag = imagA + B.imag;
0021         
0022     elseif iscstruct(A) && isnumeric(B)
0023         realB = real(B);
0024         imagB = imag(B);
0025         plusAB.real = realB + A.real;
0026         plusAB.imag = imagB + A.imag;
0027     
0028     elseif isnumeric(A) && isnumeric(B)
0029         plusAB = A + B;
0030     
0031     elseif iscstruct(A) && iscstruct(B)
0032         plusAB.real = A.real + B.real;
0033         plusAB.imag = A.imag + B.imag;
0034     
0035     else
0036         ME = MException('cplus:inputError', ...
0037                         'Input does not have the expected format.');
0038         throw(ME);
0039     end
0040 
0041 end

Generated on Fri 30-Sep-2022 13:18:25 by m2html © 2005