From 6f409bf0779273b4ec6750f3e7e83ff78bb486ab Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sat, 13 Apr 2024 16:11:45 +0000 Subject: [PATCH] TST: Add some more symbols --- trial.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/trial.c b/trial.c index 011901a77..cc32cec9b 100644 --- a/trial.c +++ b/trial.c @@ -1,5 +1,5 @@ -#include #include +#include int main() { int n = 4; @@ -7,10 +7,38 @@ int main() { double y[] = {5, 6, 7, 8}; double c = 0.5; // cosine of the angle double s = 0.5; // sine of the angle + double a = 2.0; // scalar for axpy and scal // Apply the rotation cblas_drot(n, x, 1, y, 1, c, s); + // Perform AXPY operation: y = a*x + y + cblas_daxpy(n, a, x, 1, y, 1); + + // Swap vectors x and y + cblas_dswap(n, x, 1, y, 1); + + // Copy vector x to y + cblas_dcopy(n, x, 1, y, 1); + + // Scale vector x by a + cblas_dscal(n, a, x, 1); + + // Compute dot product of x and y + double dot_product = cblas_ddot(n, x, 1, y, 1); + + // Compute sum of absolute values of elements in x + double asum = cblas_dasum(n, x, 1); + + // Compute Euclidean norm (L2 norm) of vector x + double norm = cblas_dnrm2(n, x, 1); + + // Find index of maximum absolute value in x + int index_max = cblas_idamax(n, x, 1); + + // Find index of minimum absolute value in x + int index_min = cblas_idamin(n, x, 1); + // Print the results printf("Resulting vectors:\n"); printf("x: "); @@ -23,7 +51,11 @@ int main() { printf("%f ", y[i]); } printf("\n"); + printf("Dot product: %f\n", dot_product); + printf("Asum: %f\n", asum); + printf("Norm: %f\n", norm); + printf("Index of max absolute value in x: %d\n", index_max); + printf("Index of min absolute value in x: %d\n", index_min); return 0; } -