Home > manopt > autodiff > functions_AD > cminus.m

# cminus

## PURPOSE

Computes the difference of A and B

## SYNOPSIS

function miusAB = cminus(A,B)

## DESCRIPTION

``` Computes the difference of A and B

function miusAB = cminus(A,B)

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

## CROSS-REFERENCE INFORMATION

This function calls: This function is called by:

## SOURCE CODE

```0001 function miusAB = cminus(A,B)
0002 % Computes the difference of A and B
0003 %
0004 % function miusAB = cminus(A,B)
0005 %
0006 % Returns the difference of A and B. This function can be seen as A-B but
0007 % is compatible with dlarrays and structs with fields real and imag.
0008 %
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         miusAB.real = realA - B.real;
0020         miusAB.imag = imagA - B.imag;
0021
0022     elseif iscstruct(A) && isnumeric(B)
0023         realB = real(B);
0024         imagB = imag(B);
0025         miusAB.real = realB - A.real;
0026         miusAB.imag = imagB - A.imag;
0027
0028     elseif isnumeric(A) && isnumeric(B)
0029         miusAB = A - B;
0030
0031     elseif iscstruct(A) && iscstruct(B)
0032         miusAB.real = A.real - B.real;
0033         miusAB.imag = A.imag - B.imag;
0034
0035     else
0036         ME = MException('cminus: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