The implicit declaration error is what you get when you use a function name that doesn't exist in any of your include files (or anything included by them).
As far as I understand from the article, the libmvec is an alternative implementation, but the functions themselves are coming from math.h,
so you should keep calling the existing cos() and sin() functions.
The name you specified (_ZGVbN4ua16vl_cosf) is not something you should call directly but an internal vectorized alternative that will replace the loop in your code (I must admit I have no idea how that works, but this is the optimizer's work)
If you did so well, the compiler / optimizer would automatically bring in the optimized (vectorized) version of the math function.
here is a way to see that:
Let's take the following code from the article (Link to article)
#include <math.h>
int N = 3200;
double b[3200];
double a[3200];
int main (void)
{
int i;
for (i = 0; i < N; i += 1)
{
b[i] = sin (a[i]);
}
return (0);
}
name this file test_math.c
.
now, if you compile it normally:
gcc ./test_math.c -lm
You can now use the nm command (which lists all symbols in a binary file) to check which sin symbols are compiled:
#nm -a a.out | grep sin
U sin@@GLIBC_2.2.5
The "U" hints that a symbol exists in the code but is undefined, this is because the binary file uses dynamic linking to the math library and it will be provided only when the binary file is running.
Now, you can compile the same file but this time using the optimizations (which implicitly brings in the libmvec library), and check again:
#gcc ./test_math.c -O1 -ftree-loop-vectorize -ffast-math -lm -mavx
#nm -a a.out | grep sin
U _ZGVcN4v_sin@@GLIBC_2.22
U sin@@GLIBC_2.2.5
Now you see that the binary file a.out is using the _ZGVcN4v_sin which is the optimized (vectorized) variant function. although you didn't mention it in the code.
Another tip, if you are using linux and just want to know how to use a math function you can just run the following command (as an example):
#man sin
SIN(3) Linux Programmer's Manual
NAME
sin, sinf, sinl - sine function
SYNOPSIS
#include <math.h>
double sin(double x);
float sinf(float x);
long double sinl(long double x);
Link with -lm.
This is just a snippet from the output, but you can see the the manual section you are reading is marked as SIN(3). The "3" means that this is a documentation of the LibC you are using.
You can also see which include file to use and how to link the library. (add -lm to your compilation command)