diff --git a/libvips/arithmetic/im_expntra.c b/libvips/arithmetic/im_expntra.c deleted file mode 100644 index f8eb7b8a..00000000 --- a/libvips/arithmetic/im_expntra.c +++ /dev/null @@ -1,301 +0,0 @@ -/* @(#) Calculates n^pel, with n as a parameter. - * @(#) If input is up to float, output is float, else input is the same as - * @(#) output. Does not work for complex input. - * @(#) - * @(#) int - * @(#) im_expntra( in, out, e ) - * @(#) IMAGE *in, *out; - * @(#) double e; - * @(#) - * @(#) Returns 0 on success and -1 on error - * @(#) - * - * Copyright: 1990, N. Dessipris - * - * Author: Nicos Dessipris - * Written on: 02/05/1990 - * Modified on: - * 10/12/93 JC - * - now reports total number of x/0, rather than each one. - * 1/2/95 JC - * - rewritten for PIO with im_wrapone() - * - incorrect complex code removed - * - /0 reporting removed for ease of programming - * 8/5/95 JC - * - im_expntra() adapted to make this - * 15/4/97 JC - * - oops, return(0) missing - * - M_E removed, as not everywhere - * 6/7/98 JC - * - _vec version added - * 30/8/09 - * - gtkdoc - * - tiny cleanups - */ - -/* - - This file is part of VIPS. - - VIPS is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - */ - -/* - - These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk - - */ - -#ifdef HAVE_CONFIG_H -#include -#endif /*HAVE_CONFIG_H*/ -#include - -#include -#include - -#include -#include - -#ifdef WITH_DMALLOC -#include -#endif /*WITH_DMALLOC*/ - -/* Parameters saved here. - */ -typedef struct { - int n; /* Number of bands of constants */ - double *e; /* Exponent values, one per band */ -} ExpntraInfo; - -/* Define what we do for each band element type. Single constant. - */ -#define POW1( IN, OUT ) { \ - IN *p = (IN *) in; \ - OUT *q = (OUT *) out; \ - \ - for( x = 0; x < sz; x++ ) { \ - double f = (double) p[x]; \ - \ - if( e == 0.0 && f < 0.0 ) \ - /* Division by zero! Difficult to report tho' \ - */ \ - q[x] = 0.0; \ - else \ - q[x] = pow( e, f ); \ - } \ -} - -/* Expntra a buffer. - */ -static int -expntra1_gen( PEL *in, PEL *out, int width, IMAGE *im, ExpntraInfo *inf ) -{ - const int sz = width * im->Bands; - const double e = inf->e[0]; - - int x; - - /* Expntra all non-complex input types. - */ - switch( im->BandFmt ) { - case IM_BANDFMT_UCHAR: POW1( unsigned char, float ); break; - case IM_BANDFMT_CHAR: POW1( signed char, float ); break; - case IM_BANDFMT_USHORT: POW1( unsigned short, float ); break; - case IM_BANDFMT_SHORT: POW1( signed short, float ); break; - case IM_BANDFMT_UINT: POW1( unsigned int, float ); break; - case IM_BANDFMT_INT: POW1( signed int, float ); break; - case IM_BANDFMT_FLOAT: POW1( float, float ); break; - case IM_BANDFMT_DOUBLE: POW1( double, double ); break; - - default: - g_assert( 0 ); - } - - return( 0 ); -} - -/* Define what we do for each band element type. One constant per band. - */ -#define POWN( IN, OUT ) { \ - IN *p = (IN *) in; \ - OUT *q = (OUT *) out; \ - \ - for( i = 0, x = 0; x < width; x++ ) \ - for( k = 0; k < im->Bands; k++, i++ ) { \ - double e = inf->e[k]; \ - double f = (double) p[i]; \ - \ - if( e == 0.0 && f < 0.0 ) \ - q[i] = 0.0; \ - else \ - q[i] = pow( e, f ); \ - } \ -} - -/* Expntra a buffer. - */ -static int -expntran_gen( PEL *in, PEL *out, int width, IMAGE *im, ExpntraInfo *inf ) -{ - int x, k, i; - - /* Expntra all non-complex input types. - */ - switch( im->BandFmt ) { - case IM_BANDFMT_UCHAR: POWN( unsigned char, float ); break; - case IM_BANDFMT_CHAR: POWN( signed char, float ); break; - case IM_BANDFMT_USHORT: POWN( unsigned short, float ); break; - case IM_BANDFMT_SHORT: POWN( signed short, float ); break; - case IM_BANDFMT_UINT: POWN( unsigned int, float ); break; - case IM_BANDFMT_INT: POWN( signed int, float ); break; - case IM_BANDFMT_FLOAT: POWN( float, float ); break; - case IM_BANDFMT_DOUBLE: POWN( double, double ); break; - - default: - g_assert( 0 ); - } - - return( 0 ); -} - -/** - * im_expntra_vec: - * @in: input #IMAGE - * @out: output #IMAGE - * @n: number of elements in array - * @e: array of constants - * - * im_expntra_vec() transforms element x of input to - * pow(@b, x) in output. - * It detects division by zero, setting those pixels to zero in the output. - * Beware: it does this silently! - * - * If the array of constants has one element, that constant is used for each - * image band. If the array has more than one element, it must have the same - * number of elements as there are bands in the image, and one array element - * is used for each band. - * - * See also: im_logtra(), im_powtra() - * - * Returns: 0 on success, -1 on error - */ -int -im_expntra_vec( IMAGE *in, IMAGE *out, int n, double *e ) -{ - ExpntraInfo *inf; - int i; - - if( im_piocheck( in, out ) || - im_check_uncoded( "im_expntra_vec", in ) || - im_check_noncomplex( "im_expntra_vec", in ) || - im_check_vector( "im_expntra_vec", n, in ) ) - return( -1 ); - - /* Prepare output header. - */ - if( im_cp_desc( out, in ) ) - return( -1 ); - if( im_isint( in ) ) { - out->Bbits = IM_BBITS_FLOAT; - out->BandFmt = IM_BANDFMT_FLOAT; - } - - /* Make space for a little buffer. - */ - if( !(inf = IM_NEW( out, ExpntraInfo )) || - !(inf->e = IM_ARRAY( out, n, double )) ) - return( -1 ); - for( i = 0; i < n; i++ ) - inf->e[i] = e[i]; - inf->n = n; - - /* Generate! - */ - if( n == 1 ) { - if( im_wrapone( in, out, - (im_wrapone_fn) expntra1_gen, in, inf ) ) - return( -1 ); - } - else { - if( im_wrapone( in, out, - (im_wrapone_fn) expntran_gen, in, inf ) ) - return( -1 ); - } - - return( 0 ); -} - -/** - * im_expntra: - * @in: input #IMAGE - * @out: output #IMAGE - * @e: base - * - * im_expntra() transforms element x of input to - * pow(@b, x) in output. - * It detects division by zero, setting those pixels to zero in the output. - * Beware: it does this silently! - * - * See also: im_logtra(), im_powtra() - * - * Returns: 0 on success, -1 on error - */ -int -im_expntra( IMAGE *in, IMAGE *out, double e ) -{ - return( im_expntra_vec( in, out, 1, &e ) ); -} - -/** - * im_exptra: - * @in: input #IMAGE - * @out: output #IMAGE - * - * im_exptra() transforms element x of input to - * pow(e, x) in output. - * It detects division by zero, setting those pixels to zero in the output. - * Beware: it does this silently! - * - * See also: im_logtra(), im_powtra() - * - * Returns: 0 on success, -1 on error - */ -int -im_exptra( IMAGE *in, IMAGE *out ) -{ - return( im_expntra( in, out, 2.7182818284590452354 ) ); -} - -/** - * im_exp10tra: - * @in: input #IMAGE - * @out: output #IMAGE - * - * im_exptra() transforms element x of input to - * pow(10, x) in output. - * It detects division by zero, setting those pixels to zero in the output. - * Beware: it does this silently! - * - * See also: im_logtra(), im_powtra() - * - * Returns: 0 on success, -1 on error - */ -int -im_exp10tra( IMAGE *in, IMAGE *out ) -{ - return( im_expntra( in, out, 10.0 ) ); -} diff --git a/libvips/arithmetic/im_powtra.c b/libvips/arithmetic/im_powtra.c deleted file mode 100644 index b993502e..00000000 --- a/libvips/arithmetic/im_powtra.c +++ /dev/null @@ -1,260 +0,0 @@ -/* @(#) Finds the power of an image - * @(#) Function im_powtra() assumes that the imin file - * @(#) is either memory mapped or in a buffer. - * @(#) Output image pow(imin, exponent) depends on input - * @(#) If input is up to float, output is float - * @(#) else input is the same as output - * @(#) Works on any number of bands. - * @(#) - * @(#) int im_powtra( in, out, e ) - * @(#) IMAGE *in, *out; - * @(#) double e; - * @(#) - * @(#) Returns 0 on success and -1 on error - * @(#) - * - * Copyright: 1990, N. Dessipris - * - * Author: Nicos Dessipris - * Written on: 02/05/1990 - * Modified on: - * 10/12/93 JC - * - now reports total number of x/0, rather than each one. - * 1/2/95 JC - * - rewritten for PIO with im_wrapone() - * - incorrect complex code removed - * - /0 reporting removed for ease of programming - * 15/4/97 JC - * - return( 0 ) missing, oops! - * 6/7/98 JC - * - _vec form added - * 30/8/09 - * - gtkdoc - * - tiny cleanups - */ - -/* - - This file is part of VIPS. - - VIPS is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - */ - -/* - - These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk - - */ - -#ifdef HAVE_CONFIG_H -#include -#endif /*HAVE_CONFIG_H*/ -#include - -#include -#include - -#include - -#ifdef WITH_DMALLOC -#include -#endif /*WITH_DMALLOC*/ - -/* Parameters saved here. - */ -typedef struct { - int n; - double *e; /* Exponent value */ -} PowtraInfo; - -/* Define what we do for each band element type. Single constant. - */ -#define POW1( IN, OUT ) { \ - IN *p = (IN *) in; \ - OUT *q = (OUT *) out; \ - \ - for( x = 0; x < sz; x++ ) { \ - double f = (double) p[x]; \ - \ - if( f == 0.0 && e < 0.0 ) \ - /* Division by zero! Difficult to report tho' \ - */ \ - q[x] = 0.0; \ - else \ - q[x] = pow( f, e ); \ - } \ -} - -/* Powtra a buffer. - */ -static int -powtra1_gen( PEL *in, PEL *out, int width, IMAGE *im, PowtraInfo *inf ) -{ - const int sz = width * im->Bands; - const double e = inf->e[0]; - - int x; - - /* Powtra all non-complex input types. - */ - switch( im->BandFmt ) { - case IM_BANDFMT_UCHAR: POW1( unsigned char, float ); break; - case IM_BANDFMT_CHAR: POW1( signed char, float ); break; - case IM_BANDFMT_USHORT: POW1( unsigned short, float ); break; - case IM_BANDFMT_SHORT: POW1( signed short, float ); break; - case IM_BANDFMT_UINT: POW1( unsigned int, float ); break; - case IM_BANDFMT_INT: POW1( signed int, float ); break; - case IM_BANDFMT_FLOAT: POW1( float, float ); break; - case IM_BANDFMT_DOUBLE: POW1( double, double ); break; - - default: - g_assert( 0 ); - } - - return( 0 ); -} - -/* Define what we do for each band element type. One constant per band. - */ -#define POWN( IN, OUT ) { \ - IN *p = (IN *) in; \ - OUT *q = (OUT *) out; \ - \ - for( i = 0, x = 0; x < width; x++ ) \ - for( k = 0; k < im->Bands; k++, i++ ) { \ - double e = inf->e[k]; \ - double f = (double) p[i]; \ - \ - if( f == 0.0 && e < 0.0 ) \ - q[i] = 0.0; \ - else \ - q[i] = pow( f, e ); \ - }\ -} - -/* Powtra a buffer. - */ -static int -powtran_gen( PEL *in, PEL *out, int width, IMAGE *im, PowtraInfo *inf ) -{ - int x, k, i; - - /* Powtra all non-complex input types. - */ - switch( im->BandFmt ) { - case IM_BANDFMT_UCHAR: POWN( unsigned char, float ); break; - case IM_BANDFMT_CHAR: POWN( signed char, float ); break; - case IM_BANDFMT_USHORT: POWN( unsigned short, float ); break; - case IM_BANDFMT_SHORT: POWN( signed short, float ); break; - case IM_BANDFMT_UINT: POWN( unsigned int, float ); break; - case IM_BANDFMT_INT: POWN( signed int, float ); break; - case IM_BANDFMT_FLOAT: POWN( float, float ); break; - case IM_BANDFMT_DOUBLE: POWN( double, double ); break; - - default: - g_assert( 0 ); - } - - return( 0 ); -} - -/** - * im_powtra_vec: - * @in: input #IMAGE - * @out: output #IMAGE - * @n: number of elements in array - * @e: array of constants - * - * im_powtra_vec() transforms element x of input to - * pow(x, @b) in output. - * It detects division by zero, setting those pixels to zero in the output. - * Beware: it does this silently! - * - * If the array of constants has one element, that constant is used for each - * image band. If the array has more than one element, it must have the same - * number of elements as there are bands in the image, and one array element - * is used for each band. - * - * See also: im_logtra(), im_expntra_vec() - * - * Returns: 0 on success, -1 on error - */ -int -im_powtra_vec( IMAGE *in, IMAGE *out, int n, double *e ) -{ - PowtraInfo *inf; - int i; - - if( im_piocheck( in, out ) || - im_check_uncoded( "im_powtra_vec", in ) || - im_check_noncomplex( "im_powtra_vec", in ) || - im_check_vector( "im_powtra_vec", n, in ) ) - return( -1 ); - - /* Prepare output header. - */ - if( im_cp_desc( out, in ) ) - return( -1 ); - if( im_isint( in ) ) { - out->Bbits = IM_BBITS_FLOAT; - out->BandFmt = IM_BANDFMT_FLOAT; - } - - /* Make space for a little buffer. - */ - if( !(inf = IM_NEW( out, PowtraInfo )) || - !(inf->e = IM_ARRAY( out, n, double )) ) - return( -1 ); - for( i = 0; i < n; i++ ) - inf->e[i] = e[i]; - inf->n = n; - - /* Generate! - */ - if( n == 1 ) { - if( im_wrapone( in, out, - (im_wrapone_fn) powtra1_gen, in, inf ) ) - return( -1 ); - } - else { - if( im_wrapone( in, out, - (im_wrapone_fn) powtran_gen, in, inf ) ) - return( -1 ); - } - - return( 0 ); -} - -/** - * im_powtra: - * @in: input #IMAGE - * @out: output #IMAGE - * @e: exponent - * - * im_powtra() transforms element x of input to - * pow(x, @e) in output. - * It detects division by zero, setting those pixels to zero in the output. - * Beware: it does this silently! - * - * See also: im_logtra(), im_powntra_vec() - * - * Returns: 0 on success, -1 on error - */ -int -im_powtra( IMAGE *in, IMAGE *out, double e ) -{ - return( im_powtra_vec( in, out, 1, &e ) ); -} diff --git a/libvips/arithmetic/power.c b/libvips/arithmetic/power.c new file mode 100644 index 00000000..a684ca4c --- /dev/null +++ b/libvips/arithmetic/power.c @@ -0,0 +1,353 @@ +/* power.c --- various power functions + * + * Copyright: 1990, N. Dessipris + * + * Author: Nicos Dessipris + * Written on: 02/05/1990 + * Modified on: + * 10/12/93 JC + * - now reports total number of x/0, rather than each one. + * 1/2/95 JC + * - rewritten for PIO with im_wrapone() + * - incorrect complex code removed + * - /0 reporting removed for ease of programming + * 15/4/97 JC + * - return( 0 ) missing, oops! + * 6/7/98 JC + * - _vec form added + * 30/8/09 + * - gtkdoc + * - tiny cleanups + * 20/9/09 + * - im_powtra() adapated to make power.c + */ + +/* + + This file is part of VIPS. + + VIPS is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + */ + +/* + + These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk + + */ + +#ifdef HAVE_CONFIG_H +#include +#endif /*HAVE_CONFIG_H*/ +#include + +#include +#include + +#include + +#ifdef WITH_DMALLOC +#include +#endif /*WITH_DMALLOC*/ + +/* Operator with a single constant. + */ +#define CONST1( IN, OUT, FUN ) { \ + OUT *tq = (OUT *) q; \ + OUT tc = *((OUT *) vector); \ + IN *tp = (IN *) p; \ + \ + for( i = 0; i < ne; i++ ) \ + FUN( tq[i], tp[i], tc ); \ +} + +/* Operator with a single constant on a buffer. + */ +#define CONST1_BUFFER( NAME, FUN ) \ +static void \ +NAME ## 1_buffer( PEL *p, PEL *q, int n, PEL *vector, IMAGE *im ) \ +{ \ + /* Complex just doubles the size. \ + */ \ + const int ne = n * im->Bands * (im_iscomplex( im ) ? 2 : 1); \ + \ + int i; \ + \ + switch( im->BandFmt ) { \ + case IM_BANDFMT_CHAR: \ + CONST1( signed char, float, FUN ); break; \ + case IM_BANDFMT_UCHAR: \ + CONST1( unsigned char, float, FUN ); break; \ + case IM_BANDFMT_SHORT: \ + CONST1( signed short, float, FUN ); break; \ + case IM_BANDFMT_USHORT: \ + CONST1( unsigned short, float, FUN ); break; \ + case IM_BANDFMT_INT: \ + CONST1( signed int, float, FUN ); break; \ + case IM_BANDFMT_UINT: \ + CONST1( unsigned int, float, FUN ); break; \ + case IM_BANDFMT_FLOAT: \ + CONST1( float, float, FUN ); break; \ + case IM_BANDFMT_COMPLEX: \ + CONST1( float, float, FUN ); break; \ + case IM_BANDFMT_DOUBLE: \ + CONST1( double, double, FUN ); break; \ + case IM_BANDFMT_DPCOMPLEX: \ + CONST1( double, double, FUN ); break; \ + \ + default: \ + g_assert( 0 ); \ + } \ +} + +/* Operator with one constant per band. + */ +#define CONSTN( IN, OUT, FUN ) { \ + OUT *tq = (OUT *) q; \ + IN *tp = (IN *) p; \ + OUT *tc = (OUT *) vector; \ + \ + for( i = 0, x = 0; x < n; x++ ) \ + for( b = 0; b < bands; b++, i++ ) \ + FUN( tq[i], tp[i], tc[b] ); \ +} + +/* Operator with one constant per band on a buffer. + */ +#define CONSTN_BUFFER( FUN ) \ +static void \ +FUN ## n_buffer( PEL *p, PEL *q, int n, PEL *vector, IMAGE *im ) \ +{ \ + const int bands = im->Bands; \ + \ + int i, x, b; \ + \ + switch( im->BandFmt ) { \ + case IM_BANDFMT_CHAR: \ + CONSTN( signed char, float, FUN ); break; \ + case IM_BANDFMT_UCHAR: \ + CONSTN( unsigned char, float, FUN ); break; \ + case IM_BANDFMT_SHORT: \ + CONSTN( signed short, float, FUN ); break; \ + case IM_BANDFMT_USHORT: \ + CONSTN( unsigned short, float, FUN ); break; \ + case IM_BANDFMT_INT: \ + CONSTN( signed int, float, FUN ); break; \ + case IM_BANDFMT_UINT: \ + CONSTN( unsigned int, float, FUN ); break; \ + case IM_BANDFMT_FLOAT: \ + CONSTN( float, float, FUN ); break; \ + case IM_BANDFMT_COMPLEX: \ + CONSTN( float, float, FUN ); break; \ + case IM_BANDFMT_DOUBLE: \ + CONSTN( double, double, FUN ); break; \ + case IM_BANDFMT_DPCOMPLEX: \ + CONSTN( double, double, FUN ); break; \ + \ + default: \ + g_assert( 0 ); \ + } \ +} + +#define POW( Y, X, E ) { \ + double x = (double) (X); \ + double e = (double) (E); \ + \ + if( f == 0.0 && e < 0.0 ) \ + /* Division by zero! Difficult to report tho' \ + */ \ + (Y) = 0.0; \ + else \ + (Y) = pow( f, e ); \ +} + +CONST1_BUFFER( POW ) + +CONSTN_BUFFER( POW ) + +/* Save a bit of typing. + */ +#define UC IM_BANDFMT_UCHAR +#define C IM_BANDFMT_CHAR +#define US IM_BANDFMT_USHORT +#define S IM_BANDFMT_SHORT +#define UI IM_BANDFMT_UINT +#define I IM_BANDFMT_INT + +/* Type conversions for boolean. + */ +static int bandfmt_power[10] = { +/* UC C US S UI I F X D DX */ + F, F, F, F, F, F, F, X, D, DX, +}; + +/** + * im_powtra_vec: + * @in: input #IMAGE + * @out: output #IMAGE + * @n: number of elements in array + * @e: array of constants + * + * im_powtra_vec() transforms element x of input to + * pow(x, @b) in output. + * It detects division by zero, setting those pixels to zero in the output. + * Beware: it does this silently! + * + * If the array of constants has one element, that constant is used for each + * image band. If the array has more than one element, it must have the same + * number of elements as there are bands in the image, and one array element + * is used for each band. + * + * See also: im_logtra(), im_expntra_vec() + * + * Returns: 0 on success, -1 on error + */ +int +im_powtra_vec( IMAGE *in, IMAGE *out, int n, double *c ) +{ + if( im_check_noncomplex( "im_powtra_vec", in ) ) + return( -1 ); + + return( im__arith_binary_const( "im_powtra_vec", + in, out, n, c, + bandfmt_power, + (im_wrapone_fn) POW1_buffer, + (im_wrapone_fn) POWn_buffer ) ); +} + +/** + * im_powtra: + * @in: input #IMAGE + * @out: output #IMAGE + * @e: exponent + * + * im_powtra() transforms element x of input to + * pow(x, @e) in output. + * It detects division by zero, setting those pixels to zero in the output. + * Beware: it does this silently! + * + * See also: im_logtra(), im_powntra_vec() + * + * Returns: 0 on success, -1 on error + */ +int +im_powtra( IMAGE *in, IMAGE *out, double e ) +{ + return( im_powtra_vec( in, out, 1, &e ) ); +} + +/* Converse of POW() above. + */ +#define POWC( Y, X, E ) POW( Y, E, X ) + +CONST1_BUFFER( POWC ) + +CONSTN_BUFFER( POWC ) + +/** + * im_expntra_vec: + * @in: input #IMAGE + * @out: output #IMAGE + * @n: number of elements in array + * @e: array of constants + * + * im_expntra_vec() transforms element x of input to + * pow(@b, x) in output. + * It detects division by zero, setting those pixels to zero in the output. + * Beware: it does this silently! + * + * If the array of constants has one element, that constant is used for each + * image band. If the array has more than one element, it must have the same + * number of elements as there are bands in the image, and one array element + * is used for each band. + * + * See also: im_logtra(), im_powtra() + * + * Returns: 0 on success, -1 on error + */ +int +im_expntra_vec( IMAGE *in, IMAGE *out, int n, double *c ) +{ + if( im_check_noncomplex( "im_expntra_vec", in ) ) + return( -1 ); + + return( im__arith_binary_const( "im_expntra_vec", + in, out, n, c, + bandfmt_power, + (im_wrapone_fn) POWC1_buffer, + (im_wrapone_fn) POWCn_buffer ) ); +} + +/** + * im_expntra: + * @in: input #IMAGE + * @out: output #IMAGE + * @e: base + * + * im_expntra() transforms element x of input to + * pow(@e, x) in output. + * It detects division by zero, setting those pixels to zero in the output. + * Beware: it does this silently! + * + * See also: im_logtra(), im_powtra() + * + * Returns: 0 on success, -1 on error + */ +int +im_expntra( IMAGE *in, IMAGE *out, double e ) +{ + return( im_expntra_vec( in, out, 1, &e ) ); +} + +/** + * im_exptra: + * @in: input #IMAGE + * @out: output #IMAGE + * + * im_exptra() transforms element x of input to + * pow(e, x) in output. + * It detects division by zero, setting those pixels to zero in the output. + * Beware: it does this silently! + * + * See also: im_logtra(), im_powtra() + * + * Returns: 0 on success, -1 on error + */ +int +im_exptra( IMAGE *in, IMAGE *out ) +{ + return( im_expntra( in, out, 2.7182818284590452354 ) ); +} + +/** + * im_exp10tra: + * @in: input #IMAGE + * @out: output #IMAGE + * + * im_exptra() transforms element x of input to + * pow(10, x) in output. + * It detects division by zero, setting those pixels to zero in the output. + * Beware: it does this silently! + * + * See also: im_logtra(), im_powtra() + * + * Returns: 0 on success, -1 on error + */ +int +im_exp10tra( IMAGE *in, IMAGE *out ) +{ + return( im_expntra( in, out, 10.0 ) ); +} +