TomCmplx: Difference between revisions

From TomWiki
Jump to navigationJump to search
(Created page with "The solvers in the TOMLAB suite work with real numbers. Still, some equations are more easily expressed using complex numbers. The tomCmplx class makes it possible to represent ...")
 
No edit summary
 
Line 23: Line 23:
     a*b+b*a
     a*b+b*a
    
    
   
  [[Category:tomSym]]


The set of operations allowed for tomCmplx expressions is currently very limited. Element-wise addition, subtraction, multiplication, division and exponentiation are supported, as are <tt>real()</tt>, <tt>imag()</tt>, <tt>abs()</tt> and <tt>angle()</tt> which return real-valued tomSym expressions.
The set of operations allowed for tomCmplx expressions is currently very limited. Element-wise addition, subtraction, multiplication, division and exponentiation are supported, as are <tt>real()</tt>, <tt>imag()</tt>, <tt>abs()</tt> and <tt>angle()</tt> which return real-valued tomSym expressions.


If a tomCmplx is used in an equation, then a cell array of two equations is generated; One for the real and one for the imaginary component. A complex number can never be used in an inequality, so <tt>&lt;=</tt> and <tt>&gt;=</tt> are not supported for tomCmplx. (But inequalities can be used on the real and imaginary parts, as those are normal tomSym expressions.)
If a tomCmplx is used in an equation, then a cell array of two equations is generated; One for the real and one for the imaginary component. A complex number can never be used in an inequality, so <tt>&lt;=</tt> and <tt>&gt;=</tt> are not supported for tomCmplx. (But inequalities can be used on the real and imaginary parts, as those are normal tomSym expressions.)

Latest revision as of 10:12, 26 July 2011

The solvers in the TOMLAB suite work with real numbers. Still, some equations are more easily expressed using complex numbers.

The tomCmplx class makes it possible to represent symbolic complex expressions as pairs of ordinary tomSym expressions. For example:


>> toms a b
>> z = tomCmplx(a,b)
 
z = tomCmplx(1x1):
Real part:
   a
 
Imaginary part:
   b
 
>> z2 = z.*z
 
z2 = tomCmplx(1x1):
Real part:
   a*a-b*b
 
Imaginary part:
   a*b+b*a

The set of operations allowed for tomCmplx expressions is currently very limited. Element-wise addition, subtraction, multiplication, division and exponentiation are supported, as are real(), imag(), abs() and angle() which return real-valued tomSym expressions.

If a tomCmplx is used in an equation, then a cell array of two equations is generated; One for the real and one for the imaginary component. A complex number can never be used in an inequality, so <= and >= are not supported for tomCmplx. (But inequalities can be used on the real and imaginary parts, as those are normal tomSym expressions.)