Skip to content

Commit dc7685d

Browse files
committed
Changed bc_square_vector to normal multiplication and renamed it to bc_multiply_vector
1 parent 839ef32 commit dc7685d

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

ext/bcmath/libbcmath/src/private.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ static const BC_VECTOR BC_POW_10_LUT[9] = {
8282
bcmath_compare_result _bc_do_compare (bc_num n1, bc_num n2, size_t scale, bool use_sign);
8383
bc_num _bc_do_add (bc_num n1, bc_num n2);
8484
bc_num _bc_do_sub (bc_num n1, bc_num n2);
85-
void bc_square_vector(BC_VECTOR *n1_vector, size_t n1_arr_size, BC_VECTOR *prod_vector, size_t prod_arr_size);
85+
void bc_multiply_vector(
86+
BC_VECTOR *n1_vector, size_t n1_arr_size, BC_VECTOR *n2_vector, size_t n2_arr_size, BC_VECTOR *prod_vector, size_t prod_arr_size);
8687
void _bc_rm_leading_zeros (bc_num num);
8788

8889
#endif

ext/bcmath/libbcmath/src/recmul.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,16 @@ bc_num bc_multiply(bc_num n1, bc_num n2, size_t scale)
210210
return prod;
211211
}
212212

213-
void bc_square_vector(BC_VECTOR *n1_vector, size_t n1_arr_size, BC_VECTOR *prod_vector, size_t prod_arr_size)
213+
void bc_multiply_vector(
214+
BC_VECTOR *n1_vector, size_t n1_arr_size, BC_VECTOR *n2_vector, size_t n2_arr_size, BC_VECTOR *prod_vector, size_t prod_arr_size)
214215
{
215-
if (n1_arr_size == 1) {
216-
prod_vector[0] = *n1_vector * *n1_vector;
216+
if (n1_arr_size == 1 && n2_arr_size == 1) {
217+
prod_vector[0] = *n1_vector * *n2_vector;
217218
if (prod_arr_size == 2) {
218219
prod_vector[1] = prod_vector[0] / BC_VECTOR_BOUNDARY_NUM;
219220
prod_vector[0] %= BC_VECTOR_BOUNDARY_NUM;
220221
}
221222
} else {
222-
bc_standard_vector_mul(n1_vector, n1_arr_size, n1_vector, n1_arr_size, prod_vector, prod_arr_size);
223+
bc_standard_vector_mul(n1_vector, n1_arr_size, n2_vector, n2_arr_size, prod_vector, prod_arr_size);
223224
}
224225
}

0 commit comments

Comments
 (0)