Arrays of Signed and Unsigned Chars
Manipulation ofarrays of bytes (signed or unsigned chars) is provided by the classes RWMathVec<T>, RWGenMat<T>, and RWMathArray<T>. Two typedefs are used:
 
typedef signed char SChar;
typedef unsigned char UChar;
For applications requiring only small integers, these classes may be used for high efficiency and compactness. They are also very useful for storing and manipulating graphical images and 8-bit data streams from A/D converters, digitizers, and so on. This makes it easy to take a 2-dimensional Fourier transform of a graphical image, for example:
 
#include <rw/math/genmat.h>
#include <rw/cfft2d.h>
#include <iostream.h>
 
int main()
{
// Define a matrix of unsigned chars:
RWGenMat<UChar> image;
cin >> image; // Read in the image
 
// Allocate a 2-D FFT server:
DComplexFFT2DServer serve;
 
// Calculate the Fourier Transform.
RWGenMat<DComplex> spectrum =
serve.fourier(RWConvertGenMat<UChar,DComplex>(image));
 
cout << spectrum; // Print periodogram
}
Notice that we use the integer representations of the elements for input/output of vectors of signed or unsigned chars, not the literal character constants. This can differ from the behavior of your compiler when a single element is printed on an output stream. For example, the code:
 
char a = '$';
cout << a;
prints $with most compilers. However, the code:
 
RWMathVec<SChar> a(3, '$');
cout << a;
always prints 36 36 36 with the Essential Math Module. This is because the vector classes are primarily a tool for manipulating numbers, not strings. The Essential Tools Module class RWCString should be used for manipulating strings.