Пример #1
0
void mul_alloc_real_matrix_product_smart(const real_array_t * a, const real_array_t * b, real_array_t* dest)
{
    if ((a->ndims == 1) && (b->ndims == 2)) {
        simple_alloc_1d_real_array(dest,b->dim_size[1]);
        mul_real_vector_matrix(a,b,dest);
    } else if ((a->ndims == 2) && (b->ndims == 1)) {
        simple_alloc_1d_real_array(dest,a->dim_size[0]);
        mul_real_matrix_vector(a,b,dest);
    } else if ((a->ndims == 2) && (b->ndims == 2)) {
        simple_alloc_2d_real_array(dest,a->dim_size[0],b->dim_size[1]);
        mul_real_matrix_product(a,b,dest);
    } else {
        printf("Invalid size of matrix\n");
    }
}
Пример #2
0
real_array_t mul_alloc_real_matrix_product_smart(const real_array_t a, const real_array_t b)
{
    real_array_t dest;
    if((a.ndims == 1) && (b.ndims == 2)) {
        simple_alloc_1d_real_array(&dest,b.dim_size[1]);
        mul_real_vector_matrix(&a,&b,&dest);
    } else if((a.ndims == 2) && (b.ndims == 1)) {
        simple_alloc_1d_real_array(&dest,a.dim_size[0]);
        mul_real_matrix_vector(&a,&b,&dest);
    } else if((a.ndims == 2) && (b.ndims == 2)) {
        simple_alloc_2d_real_array(&dest,a.dim_size[0],b.dim_size[1]);
        mul_real_matrix_product(&a,&b,&dest);
    } else {
        omc_assert_macro(0 == "Invalid size of matrix");
    }
    return dest;
}