X-Git-Url: https://git.llucax.com/z.facultad/75.29/dale.git/blobdiff_plain/4a91a736401518a4cfe3a7f5e814a2510fb39f40..71d12266635fa7e878d0282dcb27daec542228bd:/src/number.h diff --git a/src/number.h b/src/number.h index dfd7934..99eec8c 100644 --- a/src/number.h +++ b/src/number.h @@ -70,7 +70,8 @@ struct number // Devuelve referencia a 'átomo' i del chunk (no debería ser necesario // si la multiplicación es un método de este objeto). - native_type& operator[] (size_type i) { + native_type& operator[] (size_type i) + { return chunk[i]; } @@ -89,6 +90,7 @@ struct number friend std::ostream& operator<< (std::ostream& os, const number< NN, EE>& n); // Atributos + //private: chunk_type chunk; sign_type sign; @@ -227,19 +229,17 @@ std::ostream& operator<< (std::ostream& os, const number< N, E >& n) template < typename N, typename E > number< N, E >& number< N, E >::operator*= (const number< N, E >& n) { - number < N, E > r_op = n; - normalize_length(n); - n.normalize_length(*this); - *this = divide_n_conquer(*this, n); + //number < N, E > r_op = n; + //normalize_length(n); + //n.normalize_length(*this); + *this = naif(*this, n); return *this; } template < typename N, typename E > number< N, E > operator* (const number< N, E >& n1, const number< N, E >& n2) { - number< N, E > tmp = n1; - tmp *= n2; - return tmp; + return naif(n1, n2); } template < typename N, typename E > @@ -355,8 +355,8 @@ number < N, E > naif(const number< N, E > &u, const number< N, E > &v) * buffer. Si, es feo. */ E tmp; - tmp = (E) u.chunk[0] * (E) v.chunk[0]; - num_type tnum = num_type((N *) &tmp, 2, sign); + tmp = static_cast< E >(u.chunk[0]) * static_cast< E >(v.chunk[0]); + num_type tnum = num_type(reinterpret_cast< N* >(&tmp), 2, sign); //std::cout << "T:" << tnum << " " << tmp << "\n"; //printf("1: %lu %lu %llu\n", u.chunk[0], v.chunk[0], tmp); return tnum;