Пример #1
0
	std::pair<std::complex<T> , std::complex<T> > operator()( const ValueArray<std::complex<T> > &ref ) const {
		BOOST_STATIC_ASSERT( sizeof( std::complex<T> ) == sizeof( T ) * 2 ); // we need this for the calcMinMax-hack below
		//use complex as a two element array and find the respective minmax for the two elements
		const std::pair<T, T > minmax[] = {
			calcMinMax<T, 2>( reinterpret_cast<const T *>( &ref[0] ), ref.getLength() * 2 ),
			calcMinMax<T, 2>( reinterpret_cast<const T *>( &ref[0] ) + 1, ref.getLength() * 2 )
		};

		//also use return as two element array and stuff results from above in there
		std::pair<std::complex<T> , std::complex<T> > ret;
		T *min = reinterpret_cast<T *>( &ret.first ), *max = reinterpret_cast<T *>( &ret.second );

		for( int_fast8_t i = 0; i < 2; i++ ) {
			min[i] = minmax[i].first;
			max[i] = minmax[i].second;
		}

		return ret;
	}
Пример #2
0
	std::pair<util::color<T> , util::color<T> > operator()( const ValueArray<util::color<T> > &ref ) const {
		std::pair<util::color<T> , util::color<T> > ret;

		for( uint_fast8_t i = 0; i < 3; i++ ) {
			const std::pair<T, T> buff = calcMinMax<T, 3>( &ref[0].r + i, ref.getLength() * 3 );
			*( &ret.first.r + i ) = buff.first;
			*( &ret.second.r + i ) = buff.second;
		}

		return ret;
	}
Пример #3
0
	std::pair<T, T> operator()( const ValueArray<T> &ref ) const {
		return calcMinMax<T, 1>( &ref[0], ref.getLength() );
	}