Jive reference manual
Tuple.cpp
/************************************************************************
*
* This example demonstrates how to use the Tuple class.
*
***********************************************************************/
#include <jem/std/complex.h>
#include <jem/base/Tuple.h>
#include <jem/base/System.h>
using namespace jem;
using namespace jem::io;
typedef std::complex<double> Complex;
//-----------------------------------------------------------------------
// changeArray
//-----------------------------------------------------------------------
void changeArray ( int* a, int n )
{
if ( n )
{
a[n - 1] = 100;
}
return;
}
//-----------------------------------------------------------------------
// run
//-----------------------------------------------------------------------
int run ()
{
Writer& out = System::out ();
Tuple<int,3> a ( 0, 1, 2 );
z = 1.0;
print ( out, abs( sum( z * conj(z) ) ), endl );
print ( out, sum( norm(z) ), endl );
print ( out, abs(z), endl );
z = zadd( 0.8 + imag(z), -9 ) + 0.9;
print ( out, z, endl );
print ( out, a, endl, endl );
b = a;
b[ 0 ] = 5;
print ( out, b, endl, endl );
print ( out, a, endl, endl );
b += 1;
print ( out, b, endl, endl );
c = castTo<int> ( abs( sum( b * a ) * b - 18 ) );
print ( out, c, endl, endl );
c = castTo<int> ( where( a > b, a, b ) );
print ( out, c, endl, endl );
changeArray ( c.addr(), 3 );
print ( out, c, endl, endl );
return 0;
}
//-----------------------------------------------------------------------
// main
//-----------------------------------------------------------------------
int main ()
{
return System::exec ( & run );
}