473,406 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Segmentation Problem at 1024 size matrixes multiplication

2
I am able to compute the matrix multiplication algorithm upto 512 input square matrices of random numbers. I get a segmentation error at 1024 size input square matrices.

Expand|Select|Wrap|Line Numbers
  1. for(i=1;i<=m;i++)
  2. {
  3. for(j=1;j<=q;j++)
  4. {
  5. C[i][j]=0;
  6. for(k=1;k<=p;k++)
  7. {
  8. //printf("i %d k %d j %d",i,k,j);
  9. //printf("Aik %d Bkj%d",A[i][k],B[k][j]);
  10. float d = A[i][k]*B[k][j];
  11. C[i][j] = C[i][j] +d; 
  12. // printf("%d ",C[i][j]); 
  13. }
  14. printf("\n");
  15. printf("%d ",C[i][j]);    
  16. C[i][j]=0;
  17. }
  18. }
Mar 29 '14 #1
5 1211
weaknessforcats
9,208 Expert Mod 8TB
You need to post more code. Missing is the size of the array and the values of various variables like m, q and p.
Mar 30 '14 #2
queer
2
use dynamic memory allocation
Mar 30 '14 #3
weaknessforcats
9,208 Expert Mod 8TB
You will get a segmentation error anytime you ry to access memory you have not allocated. It doesn't matter if you allocated it (dynamic) or the compiler allocated it (static).
Apr 2 '14 #4
techboy
28
You must take care when you multiply two integers your result is not exceeding 32 bit integer.instead try using long long int (64-bit integer)
Apr 14 '14 #5
evena
1
Your loops start at 1, C/C++ indexing starts at 0, so maybe you
should: (start at 0, use < instead of <=)

for(i = 0; i < m; i++)
for(j = 0; j < q; j++)
for(k = 0; k < p; k++)

etc.
Apr 14 '14 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Ruskin | last post by:
I have developed an upload tool, that allows users to upload files (funny that). The asp form object has a 'SizeLimit' property that can be set, to prevent files being uploaded, that are too large....
11
by: mike | last post by:
hi, i am running a very big code on my pc using redhat linux. when i try to increase my array size, compile and run, i get segmentation fault. i go into the debugger, run it, it crashes right...
14
by: amitnanda | last post by:
Hi Guys, I have a matrix multiplication program in C that multiplies two matrices. When their size is 3*3 or 800*800, the program runs fine. But above that size, I get a "segmentation fault"....
38
by: Martin Jørgensen | last post by:
Hi, I allocate some memory of size_t but want to express: printf("Total amount of allocated memory is: %lu bytes.\n", (unsigned long) total_mem); in kilo-bytes. So is method 1 or 2, the...
15
by: conor.robinson | last post by:
I'm running operations large arrays of floats, approx 25,000 x 80. Python (scipy) does not seem to come close to using 4GB of wired mem, but segments at around a gig. Everything works fine on...
1
by: KinGPIN | last post by:
hi ; I have a homework about CMatrix; and i had a problem ;in my homowork i hace functions and operators written for CMatrix class(this was my first homework); it is wanted to inherite the...
4
by: John Doe | last post by:
segmentation error !!!! hi guys , i wrote this program to multiply two matrices (just the basic code without checkin 4 the condition n==p ) " #include<stdio.h> main() { int a,b,c; int...
4
by: Tosh2pointO | last post by:
Hello, I'm trying to write a program that calculates up to a 1024 x 1024 matrix using multi-threading. For example, I need to run a 1024 x 1024 using 256, 64, 16 or 4 threads. Or I need to run a 64 x...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.