Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/rational

    r53a6c2a r6c6455f  
    1212// Created On       : Wed Apr  6 17:56:25 2016
    1313// Last Modified By : Peter A. Buhr
    14 // Last Modified On : Fri Jul  7 09:34:33 2017
    15 // Update Count     : 93
     14// Last Modified On : Mon May 15 21:30:12 2017
     15// Update Count     : 90
    1616//
    1717
    18 #pragma once
     18#ifndef RATIONAL_H
     19#define RATIONAL_H
    1920
    2021#include "iostream"
     
    4647// implementation
    4748
    48 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     49forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    4950struct Rational {
    5051        RationalImpl numerator, denominator;                            // invariant: denominator > 0
     
    5354// constructors
    5455
    55 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     56forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    5657void ?{}( Rational(RationalImpl) * r );
    5758
    58 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     59forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    5960void ?{}( Rational(RationalImpl) * r, RationalImpl n );
    6061
    61 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     62forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    6263void ?{}( Rational(RationalImpl) * r, RationalImpl n, RationalImpl d );
    6364
    64 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     65forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    6566void ?{}( Rational(RationalImpl) * r, zero_t );
    6667
    67 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     68forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    6869void ?{}( Rational(RationalImpl) * r, one_t );
    6970
    70 // numerator/denominator getter
     71// getter for numerator/denominator
    7172
    72 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     73forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    7374RationalImpl numerator( Rational(RationalImpl) r );
    7475
    75 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     76forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    7677RationalImpl denominator( Rational(RationalImpl) r );
    77 
    78 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     78forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    7979[ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src );
    8080
    81 // numerator/denominator setter
     81// setter for numerator/denominator
    8282
    83 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     83forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    8484RationalImpl numerator( Rational(RationalImpl) r, RationalImpl n );
    8585
    86 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     86forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    8787RationalImpl denominator( Rational(RationalImpl) r, RationalImpl d );
    8888
    8989// comparison
    9090
    91 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     91forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    9292int ?==?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    9393
    94 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     94forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    9595int ?!=?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    9696
    97 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     97forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    9898int ?<?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    9999
    100 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     100forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    101101int ?<=?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    102102
    103 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     103forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    104104int ?>?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    105105
    106 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     106forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    107107int ?>=?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    108108
    109109// arithmetic
    110110
    111 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     111forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    112112Rational(RationalImpl) +?( Rational(RationalImpl) r );
    113113
    114 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     114forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    115115Rational(RationalImpl) -?( Rational(RationalImpl) r );
    116116
    117 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     117forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    118118Rational(RationalImpl) ?+?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    119119
    120 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     120forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    121121Rational(RationalImpl) ?-?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    122122
    123 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     123forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    124124Rational(RationalImpl) ?*?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    125125
    126 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     126forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    127127Rational(RationalImpl) ?/?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    128128
    129129// conversion
    130 forall( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); } )
     130forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); } )
    131131double widen( Rational(RationalImpl) r );
    132 forall( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl );  RationalImpl convert( double );} )
     132forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl );  RationalImpl convert( double );} )
    133133Rational(RationalImpl) narrow( double f, RationalImpl md );
    134134
    135135// I/O
    136 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     136forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    137137forall( dtype istype | istream( istype ) | { istype * ?|?( istype *, RationalImpl * ); } )
    138138istype * ?|?( istype *, Rational(RationalImpl) * );
    139139
    140 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     140forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    141141forall( dtype ostype | ostream( ostype ) | { ostype * ?|?( ostype *, RationalImpl ); } )
    142142ostype * ?|?( ostype *, Rational(RationalImpl ) );
     143
     144#endif // RATIONAL_H
    143145
    144146// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.