Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- int main(int argc, char *argv[]){
- double **A,**B,**C;
- double suma,suma_kontrolna;
- int rows;
- clock_t begin_t,end_t;
- int i,j,k;
- rows=atoi(argv[1]);
- //inicjujemy macierze
- A=(double**)malloc(rows * sizeof(double*));
- B=(double**)malloc(rows * sizeof(double*));
- C=(double**)malloc(rows * sizeof(double*));
- for(i=0; i < rows; i++){
- A[i] = (double*)malloc(rows * sizeof(double));
- B[i] = (double*)malloc(rows * sizeof(double));
- C[i] = (double*)malloc(rows * sizeof(double));
- }
- //wypelnaimy macierze wartosciami
- for(i=0; i < rows; i++){
- for(j=0; j < rows; j++){
- A[i][j] = (double)(1 + i * rows +j);
- B[i][j] = (double)(1 + i * rows +j +rows*rows);
- }
- }
- printf("A: %f %f \n",A[0][0],A[0][1]);
- printf("A: %f %f \n",A[1][0],A[1][1]);
- printf("B: %f %f \n",B[0][0],B[0][1]);
- printf("B: %f %f \n",B[1][0],B[1][1]);
- begin_t=clock();
- for(i=0; i<rows; i++){
- for(j=0; j<rows; j++){
- C[i][j]=0;
- for(=0; k<rows; k++){
- C[i][j] += A[i][k] * B[k][j];
- }
- }
- }
- end_t=clock();
- printf("C: %f %f \n",C[0][0],C[0][1]);
- printf("C: %f %f \n",C[1][0],C[1][1]);
- printf("\n");
- suma_kontrolna=0;
- for(i=0;i<rows; i++){
- }
- }
- //kompilacja:
- //gcc program.c -o progrx
- //uruchomienie
- //./progrx rows
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement