[patch] view_cast function for type conversions; rename is_nan; misc

Jules Bergmann jules at codesourcery.com
Tue Oct 31 16:53:31 UTC 2006

This patch adds a view_cast function to perform type conversions on 
views.  For example, to convert a floating point matrix into a char 
matrix (suitable for grayscale display), you could:

	Matrix<float> data(rows, cols);
	Matrix<char>  img (rows, cols);

	float minv  = minval(data, idx);
	float maxv  = maxval(data, idx);
	float scale = 255.f / (maxv - minv);
	img = view_cast<char>((data - minv) * scale);

It also renames the isnan functions to is_nan since isnan from 
math.h/cmath will typically be a macro.  The previous version worked 
with GCC, whose cmath captures the isnan macro into a function.  However 
it was broken with GreenHills.  The new version works with both compilers.

Finally, it includes some misc fixes.

				-- Jules

Jules Bergmann
jules at codesourcery.com
(650) 331-3385 x705
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: misc.diff
URL: <http://sourcerytools.com/pipermail/vsipl++/attachments/20061031/6e40adce/attachment.ksh>

More information about the vsipl++ mailing list