Browse Source

TST: Add some more symbols

pull/4832/head
Rohit Goswami Mateusz Sokół 1 year ago
parent
commit
6f409bf077
1 changed files with 34 additions and 2 deletions
  1. +34
    -2
      trial.c

+ 34
- 2
trial.c View File

@@ -1,5 +1,5 @@
#include <cblas.h>
#include <stdio.h>
#include <cblas.h>

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;
}


Loading…
Cancel
Save