Skip to content

Sample program error #261

Open
Open
@EricZequan

Description

@EricZequan

Describe the bug

In the C program sample code in the readme:

#include <simsimd/simsimd.h>

int main() {
    simsimd_flush_denormals(); // Optional, to avoid performance penalties on denormal numbers

    simsimd_f32_t vector_a[1536];
    simsimd_f32_t vector_b[1536];
    simsimd_kernel_punned_t distance_function = simsimd_metric_punned(
        simsimd_metric_cos_k,   // Metric kind, like the angular cosine distance
        simsimd_datatype_f32_k, // Data type, like: f16, f32, f64, i8, b8, and complex variants
        simsimd_cap_any_k);     // Which CPU capabilities are we allowed to use
    simsimd_distance_t distance;
    distance_function(vector_a, vector_b, 1536, &distance);
    return 0;
}

it will throw a error : error: too many arguments to function call, expected 1, have 4
and I find the simsimd_kernel_punned_t:

/**
 *  @brief  Type-punned function pointer for a SimSIMD public interface.
 *
 *  Can be a `simsimd_metric_dense_punned_t`, `simsimd_metric_sparse_punned_t`, `simsimd_metric_curved_punned_t`,
 *  `simsimd_kernel_fma_punned_t`, or `simsimd_kernel_wsum_punned_t`.
 */
typedef void (*simsimd_kernel_punned_t)(void *);

I think it should be written like this?

simsimd_kernel_punned_t distance_function = simsimd_metric_punned(
        simsimd_metric_cos_k,   // Metric kind, like the angular cosine distance
        simsimd_datatype_f32_k, // Data type, like: f16, f32, f64, i8, b8, and complex variants
        simsimd_cap_any_k);     // Which CPU capabilities are we allowed to use
simsimd_distance_t distance;
metric = reinterpret_cast<simsimd_metric_dense_punned_t>(distance_function);
metric(vector_a, vector_b, 1536, &distance);

I don't know if it's a problem with my code or the readme document has not been updated. Could you please check it?

Steps to reproduce

Sample code issues

Expected behavior

run code successfully

SimSIMD version

v6.2.3

Operating System

macOS

Hardware architecture

Arm

Which interface are you using?

C implementation

Contact Details

No response

Are you open to being tagged as a contributor?

  • I am open to being mentioned in the project .git history as a contributor

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions