Changeset a1edafa for src/libcfa


Ignore:
Timestamp:
Jul 21, 2017, 5:28:45 PM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
6b0b624
Parents:
6d54c3a
Message:

move exponential implementation from math to builtin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/math

    r6d54c3a ra1edafa  
    1010// Created On       : Mon Apr 18 23:37:04 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 20 21:45:07 2017
    13 // Update Count     : 77
     12// Last Modified On : Fri Jul 21 17:03:13 2017
     13// Update Count     : 101
    1414//
    1515
     
    8383static inline double _Complex pow( double _Complex x, double _Complex y ) { return cpow( x, y ); }
    8484static inline long double _Complex pow( long double _Complex x, long double _Complex y ) { return cpowl( x, y ); }
    85 
    86 static inline float ?\?( float x, float y ) { return powf( x, y ); }
    87 static inline double ?\?( double x, double y ) { return pow( x, y ); }
    88 static inline long double ?\?( long double x, long double y ) { return powl( x, y ); }
    89 static inline float _Complex ?\?( float _Complex x, _Complex float y ) { return cpowf(x, y ); }
    90 static inline double _Complex ?\?( double _Complex x, _Complex double y ) { return cpow( x, y ); }
    91 static inline long double _Complex ?\?( long double _Complex x, _Complex long double y ) { return cpowl( x, y ); }
    92 
    93 static inline float ?\=?( float * x, float y ) { *x = *x \ y; return *x; }
    94 static inline double ?\=?( double * x, double y ) { *x = *x \ y; return *x; }
    95 static inline long double ?\=?( long double * x, long double y ) { *x = *x \ y; return *x; }
    96 static inline float _Complex ?\=?( float _Complex * x, _Complex float y ) { *x = *x \ y; return *x; }
    97 static inline double _Complex ?\=?( double _Complex * x, _Complex double y ) { *x = *x \ y; return *x; }
    98 static inline long double _Complex ?\=?( long double _Complex * x, _Complex long double y ) { *x = *x \ y; return *x; }
    99 
    100 static inline long int ?\?( long int x, unsigned long y ) {     // disallow negative exponent
    101     if ( y == 0 ) return 1;
    102     if ( x == 2 ) return x << (y - 1);
    103     long int prod = 1;
    104     for ( unsigned int i = 0; i < y; i += 1 ) {
    105                 prod = prod * x;
    106     } // for
    107     return prod;
    108 }
    109 static inline double ?\?( long int x, signed long y ) { // allow negative exponent
    110     if ( y >=  0 ) return (double)(x \ (unsigned int)y);
    111     else return 1.0 / x \ (unsigned int)(-y);
    112 }
    113 static inline forall( otype T | { void ?{}( T * this, one_t ); T ?*?( T, T ); } )
    114 T ?\?( T x, unsigned long y ) {
    115     T prod = 1;
    116     for ( unsigned int i = 1; i < y; i += 1 ) {
    117                 prod = prod * x;
    118     } // for
    119     return prod;
    120 }
    121 static inline long int ?\=?( long int * x, unsigned long y ) { *x = *x \ y; return *x; }
    122 static inline int ?\=?( int * x, unsigned long y ) { *x = *x \ y; return *x; }
    12385
    12486//---------------------- Logarithm ----------------------
Note: See TracChangeset for help on using the changeset viewer.