@@ -72,28 +72,6 @@ static inline void bc_fast_mul(bc_num n1, size_t n1len, bc_num n2, size_t n2len,
7272 }
7373}
7474
75- /*
76- * Equivalent of bc_fast_mul for small numbers to perform computations
77- * without using array.
78- */
79- static inline void bc_fast_square (bc_num n1 , size_t n1len , bc_num * prod )
80- {
81- const char * n1end = n1 -> n_value + n1len - 1 ;
82-
83- BC_VECTOR n1_vector = bc_partial_convert_to_vector (n1end , n1len );
84- BC_VECTOR prod_vector = n1_vector * n1_vector ;
85-
86- size_t prodlen = n1len + n1len ;
87- * prod = bc_new_num_nonzeroed (prodlen , 0 );
88- char * pptr = (* prod )-> n_value ;
89- char * pend = pptr + prodlen - 1 ;
90-
91- while (pend >= pptr ) {
92- * pend -- = prod_vector % BASE ;
93- prod_vector /= BASE ;
94- }
95- }
96-
9775/* Common part of functions bc_standard_mul and bc_standard_square
9876 * that takes a vector and converts it to a bc_num */
9977static inline void bc_mul_finish_from_vector (BC_VECTOR * prod_vector , size_t prod_arr_size , size_t prodlen , bc_num * prod ) {
@@ -180,55 +158,6 @@ static void bc_standard_mul(bc_num n1, size_t n1len, bc_num n2, size_t n2len, bc
180158 }
181159}
182160
183- /** This is bc_standard_mul implementation for square */
184- static void bc_standard_square (bc_num n1 , size_t n1len , bc_num * prod )
185- {
186- size_t i ;
187- const char * n1end = n1 -> n_value + n1len - 1 ;
188- size_t prodlen = n1len + n1len ;
189-
190- size_t n1_arr_size = BC_ARR_SIZE_FROM_LEN (n1len );
191- size_t prod_arr_size = BC_ARR_SIZE_FROM_LEN (prodlen );
192-
193- BC_VECTOR * buf = safe_emalloc (n1_arr_size + n1_arr_size + prod_arr_size , sizeof (BC_VECTOR ), 0 );
194-
195- BC_VECTOR * n1_vector = buf ;
196- BC_VECTOR * prod_vector = n1_vector + n1_arr_size + n1_arr_size ;
197-
198- for (i = 0 ; i < prod_arr_size ; i ++ ) {
199- prod_vector [i ] = 0 ;
200- }
201-
202- /* Convert to BC_VECTOR[] */
203- bc_convert_to_vector (n1_vector , n1end , n1len );
204-
205- /* Multiplication and addition */
206- size_t count = 0 ;
207- for (i = 0 ; i < n1_arr_size ; i ++ ) {
208- /*
209- * This calculation adds the result multiple times to the array entries.
210- * When multiplying large numbers of digits, there is a possibility of
211- * overflow, so digit adjustment is performed beforehand.
212- */
213- if (UNEXPECTED (count >= BC_VECTOR_NO_OVERFLOW_ADD_COUNT )) {
214- bc_mul_carry_calc (prod_vector , prod_arr_size );
215- count = 0 ;
216- }
217- count ++ ;
218- for (size_t j = 0 ; j < n1_arr_size ; j ++ ) {
219- prod_vector [i + j ] += n1_vector [i ] * n1_vector [j ];
220- }
221- }
222-
223- bc_mul_finish_from_vector (prod_vector , prod_arr_size , prodlen , prod );
224-
225- efree (buf );
226- }
227-
228- /* The multiply routine. N2 times N1 is put int PROD with the scale of
229- the result being MIN(N2 scale+N1 scale, MAX (SCALE, N2 scale, N1 scale)).
230- */
231-
232161bc_num bc_multiply (bc_num n1 , bc_num n2 , size_t scale )
233162{
234163 bc_num prod ;
0 commit comments