Пример #1
0
int InitNe10() {
    if(Ne10Stated==NE10_OK)
        return 0;

    Ne10Stated = ne10_init();
    if (Ne10Stated != NE10_OK) {
        printf ("\nNE10 init failed.\n");
        return -1;
    }

    printf ("\nNE10 has been initialized.\n");
    return 0;

}
Пример #2
0
/**
 * @brief An example of using the matrix multiply functions.
 */
int matrix_multiply_sample_main(void)
{
    ne10_mat3x3f_t src[MATRICES]; // A source array of `MATRICES` input matrices
    ne10_mat3x3f_t mul[MATRICES]; // An array of matrices to multiply those in `src` by
    ne10_mat3x3f_t dst[MATRICES]; // A destination array for the multiplication results

    // Initialise Ne10, using hardware auto-detection to set library function pointers.
    if (ne10_init() != NE10_OK)
    {
        fprintf(stderr, "Failed to initialise Ne10.\n");
        return 1;
    }

    // Generate test input values
    for (int i = 0; i < MATRICES; i++)
    {
        initialise_matrix(&src[i]);
        initialise_matrix(&mul[i]);
    }

    // Perform the multiplication of the matrices in `src` by those in `mul`
    ne10_mulmat_3x3f (dst, src, mul, MATRICES);

    // Display the results (src[i] * mul[i] == dst[i])
    for (int i = 0; i < MATRICES; i++)
    {
        printf("[ %5.2f %5.2f %5.2f     [ %5.2f %5.2f %5.2f     [ %5.2f %5.2f %5.2f\n",
            src[i].c1.r1, src[i].c2.r1, src[i].c3.r1,
            mul[i].c1.r1, mul[i].c2.r1, mul[i].c3.r1,
            dst[i].c1.r1, dst[i].c2.r1, dst[i].c3.r1);
        printf("  %5.2f %5.2f %5.2f   *   %5.2f %5.2f %5.2f   =   %5.2f %5.2f %5.2f\n",
            src[i].c1.r2, src[i].c2.r2, src[i].c3.r2,
            mul[i].c1.r2, mul[i].c2.r2, mul[i].c3.r2,
            dst[i].c1.r2, dst[i].c2.r2, dst[i].c3.r2);
        printf("  %5.2f %5.2f %5.2f ]     %5.2f %5.2f %5.2f ]     %5.2f %5.2f %5.2f ]\n",
            src[i].c1.r3, src[i].c2.r3, src[i].c3.r3,
            mul[i].c1.r3, mul[i].c2.r3, mul[i].c3.r3,
            dst[i].c1.r3, dst[i].c2.r3, dst[i].c3.r3);
        printf("\n");
    }

    return 0;
}