banner

Thursday, July 7, 2022

standard matrix multiplication code in basic c language

 #include <stdio.h>

int main() {

//elements we took mat1: 2X3 and  mat2: 3X2

    int a[2][3]= {4,1,2,3,1,2};

    int b[3][2]= {4,1,2,3,1,2};

    int c[2][2]= {0,0,0,0};

    int d[2][2]= {0,0,0,0};

    int ca=3,ra=2,cb=2,rb=3;

    int w,x,y,z,i,j,k;

    for (i=0; i<ra; i++){

        for (j=0; j<cb; j++){

            for (k=0; k<ca; k++){

                x= a[i][k];

                y= b[k][j];

               // z= c[i][j];

                printf("i=%d, k=%d, j=%d\n",i,k,j);

                z=w;

                w= (x * y)+z;

                printf("w=%d, x=%d, y=%d, z=%d \n",w,x,y,z);

            }

            if (k==ca) {k=0;d[i][j]=w;w=0;}

            printf("d[%d][%d]:%d\n",i,j,d[i][j]);

        }

       if (j==cb) j=0; 

    }

    return 0;

}

programiz link: https://www.programiz.com/c-programming/online-compiler/




No comments:

PULP RISC-V important links

1) Understanding and working with PULP - all the details of the architectures https://pulp-platform.org/docs/riscv_workshop_zurich/schiavone...