473,395 Members | 1,706 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,395 software developers and data experts.

General Protection Error in C++ code

Hi I am trying to do a program on convolution, that is, multiplying 2 non-multipliable matrices. Here is the code. I even know where I'm getting an error. It's on line 20. Please help me out. Why am I getting this error?

Expand|Select|Wrap|Line Numbers
  1. #include<iostream.h>
  2. #include<stdio.h>
  3. #include<conio.h>
  4.  
  5.  
  6. void main()
  7. {
  8.  int a[5][5], b[10][10], t[20][10][10], res[10][10];
  9.  int i, j, k, x;
  10.  cout<<"Enter matrix 1 : \n";
  11.  for(i=0; i<3; i++)
  12.   for(j=0; j<3; j++)
  13.     cin>>a[i][j];
  14.  cout<<"Enter matrix 2 : \n";
  15.  for(i=1; i<5; i++)
  16.   for(j=1; j<5; j++)
  17.     cin>>b[i][j];
  18.  for(i=0, j=0; j<6; j++)
  19.  {
  20.   b[i][j] = b[j][i] = b[5-i][j] = b[j][5-i] = 0;
  21.  }
  22.  for(x=0; x<16; x++)
  23.  {
  24.   res[x/4][x%4]=0;
  25.   for(i=0; i<3; i++)
  26.   {
  27.     for(j=0; j<3; j++)
  28.     {
  29.      t[x][i][j] = 0;
  30.      for(k=0; k<3; k++)
  31.      {
  32.       t[x][i][j] += a[i][k]*b[k+x/4][j+x%4];
  33.      }
  34.      res[x/4][x%4] += t[x][i][j];
  35.     }
  36.   }
  37.  
  38.  }
  39.  
  40.  cout<<"The resultant matrix is :\n";
  41.  for(i=0; i<4; i++)
  42.  {
  43.   for(j=0; j<4; j++)
  44.   {
  45.     cout<<res[i][j]<<" ";
  46.   }
  47.   cout<<endl;
  48.  }
  49.  
  50.  getch();
  51. }
Jan 24 '13 #1
4 1808
PS -
The error is in the for loop probably in the line -
b[i][j] = b[j][i] = b[5-i][j] = b[j][5-i] = 0;
Please help!
Jan 24 '13 #2
Can u explain what is meant by convolution, and give some sample input and output to make it clear.
Jan 25 '13 #3
Anas Mosaad
185 128KB
Convolution is a term used in pattern matching to determine the overlaps between two input matrices. For example, if you are searching for letter A in a photo, you would multiply the A matrix in different pieces from the photo matrix until you detect the overlaps (i.e. matches). Hope it's clear now.
Jan 25 '13 #4
Banfa
9,065 Expert Mod 8TB
Trying out your code unmodified and inputting 1 for all items produces a result with no crash.

Visual inspection of the code shows no reason for a crash to happen.

Without further information I am not sure there is much more we can do.
Jan 28 '13 #5

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

Similar topics

2
by: stanley j Mroczek | last post by:
Every thing is on one machine, Programs and sql. Sql is up and running(can test with query analyzer). No changes where made! This was working fine. How do you track this error? What network...
2
by: SteveS | last post by:
Hello all. This problem is stumping me.... I run a page called "default.aspx". For some reason when I execute this page, I get the error below. It seems to run through the entire code behind...
7
by: stan | last post by:
I have .net 2003 and SQL 2000 setup on one system. All I have is one computer (no network). I am able to get to the internet that works. I can run SQL Query Analyzer and it works. The program was...
0
by: Paiman Allage | last post by:
Hello all, I hope you can help me. I have developed an ".NET" application and started to deploy the application. However, I am haveing a problem, where when I compile the program on my laptop,...
3
by: Yong | last post by:
I get a general network error when I try to make asynchronously call ExecuteNonQuery on long sql statements that run in parallel. Here is the background info on what I'm trying to accomplish: I...
37
by: dmoran21 | last post by:
I am a mathematician trying to write a program in C to do some curve fitting. When I get to the point where I attempt to enter data in my arrays, I get a General Protection Exception error message....
2
by: akmkat | last post by:
When I try to compile the following code with N = 1024, "General Protection Exception" occurs, but wehn N < 20, there is no problem. I need N = 1024, what'll I do? Plz help anyone #include...
1
by: manhquynh8x | last post by:
I am programming a data compession program. It is used to compress a text file. After run program, i see this message: Exception 13: General protection fault at o1A7.. The compiler is Turbo C++...
2
by: subhasree | last post by:
Hi, I am a student of mathematics and quite new to programming in C. I am trying to write a code to construct an array which at every step has to compare the value of the current element with all...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.