Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 #include "rtos.h" 00003 00004 00005 double *A,*B,*C; 00006 int i,j,k,N; 00007 Serial pc(USBTX, USBRX); // tx, rx 00008 00009 void process1_thread(void const *args) 00010 { 00011 for(i=0; i<N/2; i++) { 00012 for(j=0; j<N; j++) { 00013 C[i*N+j]=0; 00014 for(k=0; k<N; k++) { 00015 C[i*N+j]= C[i*N+j] + A[i*N+k]*B[k+j*N]; 00016 } 00017 } 00018 } 00019 } 00020 00021 void process2_thread(void const *args) 00022 { 00023 for(i=N/2; i<N; i++) { 00024 for(j=0; j<N; j++) { 00025 C[i*N+j]=0; 00026 for(k=0; k<N; k++) { 00027 C[i*N+j]= C[i*N+j] + A[i*N+k]*B[k+j*N]; 00028 } 00029 } 00030 } 00031 } 00032 00033 00034 int main() 00035 { 00036 00037 N=10; 00038 //Inicialize matrix 00039 for(i=0; i<N; i++) { 00040 for(j=0; j<N; j++) { 00041 A[i*N+j]=1; 00042 B[i+j*N]=1; 00043 } 00044 } 00045 00046 Thread thread1(process1_thread); 00047 Thread thread2(process2_thread); 00048 00049 //Print Results 00050 for (i=0;i<N;i++){ 00051 for(j=0;j<N;j++){ 00052 pc.printf("%d ",C[i*N+j]); 00053 } 00054 pc.printf("\n"); 00055 } 00056 }
Generated on Mon Aug 15 2022 08:53:56 by
1.7.2