Library/ManagedCuda/CudaHelperMethods.cs
/// <summary>
/// Returns the number of channels used in textures depending on the given type.
/// </summary>
/// <param name="value">Type</param>
/// <returns>Number of channels</returns>
Returns the number of channels used in textures depending on the given type.
Returns the number of channels used in textures depending on the given type .
public static int GetNumChannels(System.Type value)
        {
            if (value == typeof(char4) || value == typeof(uchar4) || value == typeof(short4) || value == typeof(ushort4) || value == typeof(int4) ||
                value == typeof(uint4) || value == typeof(long4) || value == typeof(ulong4) || value == typeof(float4))
                return 4;
            if (value == typeof(char2) || value == typeof(uchar2) || value == typeof(short2) || value == typeof(ushort2) || value == typeof(int2) ||
                value == typeof(uint2) || value == typeof(long2) || value == typeof(ulong2) || value == typeof(float2) || value == typeof(double2) ||
                value == typeof(cuFloatComplex) || value == typeof(cuDoubleComplex))
                return 2;
            if (value == typeof(byte) || value == typeof(sbyte) || value == typeof(short) || value == typeof(ushort) || value == typeof(int) || value == typeof(uint) ||
                value == typeof(long) || value == typeof(ulong) || value == typeof(float) || value == typeof(double) ||
                value == typeof(char1) || value == typeof(uchar1) || value == typeof(short1) || value == typeof(ushort1) || value == typeof(int1) ||
                value == typeof(uint1) || value == typeof(long1) || value == typeof(ulong1) || value == typeof(float1) || value == typeof(double1) ||
                value == typeof(cuFloatReal) || value == typeof(cuDoubleReal))
                return 1;
            throw new ArgumentException("Argument type must either be of 1, 2 or 4 channels. E.g. float1, float2, float4");
        }
public static int GetNumChannels ( System . Type value ) { if ( value == typeof ( char4 ) || value == typeof ( uchar4 ) || value == typeof ( short4 ) || value == typeof ( ushort4 ) || value == typeof ( int4 ) || value == typeof ( uint4 ) || value == typeof ( long4 ) || value == typeof ( ulong4 ) || value == typeof ( float4 ) ) return 4 ; if ( value == typeof ( char2 ) || value == typeof ( uchar2 ) || value == typeof ( short2 ) || value == typeof ( ushort2 ) || value == typeof ( int2 ) || value == typeof ( uint2 ) || value == typeof ( long2 ) || value == typeof ( ulong2 ) || value == typeof ( float2 ) || value == typeof ( double2 ) || value == typeof ( cuFloatComplex ) || value == typeof ( cuDoubleComplex ) ) return 2 ; if ( value == typeof ( byte ) || value == typeof ( sbyte ) || value == typeof ( short ) || value == typeof ( ushort ) || value == typeof ( int ) || value == typeof ( uint ) || value == typeof ( long ) || value == typeof ( ulong ) || value == typeof ( float ) || value == typeof ( double ) || value == typeof ( char1 ) || value == typeof ( uchar1 ) || value == typeof ( short1 ) || value == typeof ( ushort1 ) || value == typeof ( int1 ) || value == typeof ( uint1 ) || value == typeof ( long1 ) || value == typeof ( ulong1 ) || value == typeof ( float1 ) || value == typeof ( double1 ) || value == typeof ( cuFloatReal ) || value == typeof ( cuDoubleReal ) ) return 1 ; throw new ArgumentException ( " " ) ; }
Returns the number of channels used in textures depending on the given type.
Returns the number of channels used in textures depending on the given type .
Number of channels
Number of channels
value
System.Type
None