Hello
I am using a subroutine to solve relatively large matrix in C++
but I got an error with this text
"The exception unknown software exception (0x0000005) occurred in the application at location 0x0040a97a"
I know that this is an error in memory allocation. my computer has 16GB RAM memory. but I dont know how to use it to solve a matrix greater than 10000x10000.
right now I can not solve matrices greater than 4000x4000.
I appreciate anyone help me
Thanks
Reza
10 1858
Hello
I am using a subroutine to solve relatively large matrix in C++
but I got an error with this text
"The exception unknown software exception (0x0000005) occurred in the application at location 0x0040a97a"
I know that this is an error in memory allocation. my computer has 16GB RAM memory. but I dont know how to use it to solve a matrix greater than 10000x10000.
right now I can not solve matrices greater than 4000x4000.
I appreciate anyone help me
Thanks
Reza
Are you allocating memory for this statically or dynamically?
Raghuram
Are you allocating memory for this statically or dynamically?
Raghuram
I am allocating memory dynamically by pointers.
Let's see your allocation.
And what operating system are you using??
And what compiler??
the operating system is windows xp and compiler is C++
is there any way that I specify the amount of memory which should be used?
I mean because my computer has 16 GB RAM but I am sure that I am not using it.
thanks
the operating system is windows xp and compiler is C++
is there any way that I specify the amount of memory which should be used?
I mean because my computer has 16 GB RAM but I am sure that I am not using it.
thanks
Windows Xp can't make use of that RAM amount,maximum it can use is 3.5GB.You will need to install Windows Vista x64(Win Xp x64 for some reason also only uses 3.5GB of RAM).
Also how are you solving those matrices,with recursion?
If so it's no wonder you couldn't solve matrix that big.It takes a lot of space even if you make every entry to be a 1B char.
Savage
I am using LU decomposition to solve it.
the operating system is xp 64.
is there any way to make the program to work?
Reza2: You still haven't shown me your code for your allocation.
The memory you allocate has nothing to do woth the memory in your computer. Check out the section on Memory Management in Windows via C/C++ by Jeffrey Richter 2008.
I have attached the solver part of my code.
you can see its error.
matrix size is 10000x1000.
#include<math.h>
#include<fstream.h>
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include <iomanip.h>
#include <stdio.h>
#include <time.h>
#include <malloc.h>
#include <stdio.h>
#include <math.h>
//************* INPUT Data ************************************************** ******************
const int Nx=100; // no. of fine scale grid in x direction
const int Ny=100; // no. of fine scale grid in y direction
//************************** Variables Arrays *****************************************
double **a,**l,**u,*b,*x;
int i,j,k,n;
//***************************** Subroutines and Functions *************************************/
void linbcg(unsigned long n, double b[], double x[], int itol, double tol,
int itmax, int *iter, double *err);
void solver(double **a,double **u,double **l, double *b,int n,int N); // Solver subroutine
int min(int r,int s); //
int max(int r,int s);
void main()
{
//******************** Matrix Decleration ************************************************** ****
n=Nx*Ny;
b=new double [n+1];
x=new double [n+1];
a=new double *[n+1];
l=new double *[n+1];
u=new double *[n+1];
for(i=0;i<=n;i++){
a[i]=new double [n+1];
l[i]=new double [n+1];
u[i]=new double [n+1];
}
//********* a[][]***************** adjacency matrix
for(j=1;j<=n;j++)
for(i=1;i<=n;i++)
a[i][j]=0.0;
j=1;
for(i=1;i<=Nx;i++){
k=Nx*(j-1)+i;
a[k][k]=4.9;
}
for(j=2;j<Ny;j++)
for(i=1;i<=Nx;i++){
k=Nx*(j-1)+i;
a[k][k]=5;
}
j=Ny;
for(i=1;i<=Nx;i++){
k=Nx*(j-1)+i;
a[k][k]=4.9;
}
for(j=1;j<=Ny;j++)
for(i=1;i<Nx;i++){
k=Nx*(j-1)+i;
a[k][k+1]=2.2;
}
for(j=1;j<=Ny;j++)
for(i=2;i<=Nx;i++){
k=Nx*(j-1)+i;
a[k][k-1]=2.2;
}
for(j=1;j<=Ny-1;j++)
for(i=1;i<=Nx;i++){
k=Nx*(j-1)+i;
a[k][k+Nx]= 2.4;
}
for(j=2;j<=Ny;j++)
for(i=1;i<=Nx;i++){
k=Nx*(j-1)+i;
a[k][k-Nx]=2.4;
}
ofstream matrixA("A.dat",ios::in);
for (j=1;j<=n;j++)
{
for (i=1;i<=n;i++)
{
matrixA<<a[i][j]<<" \t";
}
matrixA<<"\n";
}
//********************b[]********** Forcing function matrix ****************************
for(j=1;j<=Ny;j++)
for(i=1;i<=Nx;i++){
k=Nx*(j-1)+i;
b[k]=(0.0);
}
i=1;
for(j=1;j<=Ny;j++)
{
k=Nx*(j-1)+1;
b[k]= 6;
}
i=Nx;
for(j=1;j<=Ny;j++)
{
k=Nx*(j-1)+Nx;
b[k]= 1;
}
//********** solver *********************************************
solver(a,u,l,b,n,Nx);
for(j=1;j<=Ny;j++)
for(i=1;i<=Nx;i++)
{
k=Nx*(j-1)+i;
x[k]=b[k];
}
for(j=1;j<=Ny;j++)
for(i=1;i<=Nx;i++)
{
k=Nx*(j-1)+i;
cout<<"x("<<k<<","<<i<<","<<j<<"]="<<x[k]<<endl;
}
}
//************************************************** ***********************************************
//*********************** subroutin Matrix solver ***************************************
void solver(double **a,double **u,double **l, double *b,int n,int N)
{
int i,j,k,mi,mx;
double zig,sig;
int p=N+1; int q=N+1;
//******* LU decomposition *********************
for(k=1;k<=n-1;k++){
mi=min(k+p,n);
for(i=k+1;i<=mi;i++)
a[i][k]=a[i][k]/a[k][k];
for(i=k+1;i<=mi;i++){
mi=min(k+q,n);
for(j=k+1;j<=mi;j++)
a[i][j]=a[i][j]-a[i][k]*a[k][j];
}
}
for(i=1;i<=n;i++)
for(j=1;j<=n;j++){
l[i][j]=0.0;
u[i][j]=0.0;
}
/// matrix L[][] ////
for(i=1;i<=n;i++){
for(j=1;j<i;j++)
l[i][j]=a[i][j];
}
//////matrix U[][] //////////////
for(i=1;i<=n;i++){
for(j=i;j<=n;j++)
u[i][j]=a[i][j];
}
///// overwriting b[] for L[][] matrix
for(i=1;i<=n;i++){
mx=max(1,i-p);
zig=0.0;
for(j=mx;j<=i-1;j++)
zig=zig+l[i][j]*b[j];
b[i]=b[i]-zig;
}
/// solution matrix x[] for UX=Y
for(i=n;i>=1;i--){
mi=min(i+q,n);
sig=0.0;
for(j=i+1;j<=mi;j++)
sig=sig+u[i][j]*b[j];
b[i]=(b[i]-sig)/u[i][i];
}
}
int min(int r,int s){
int mini=0;
mini=r;
if(s<r) mini=s;
return mini ;
}
int max(int r,int s){
int mxi=0;
mxi=r;
if(s>r) mxi=s;
return mxi;
}
if you know how can I debug it just let me know.
Thanks
Are you freeing this memory?
Savage
Not actually.
because it has the problem from the beginning.
Are you freeing this memory?
Savage
Sign in to post your reply or Sign up for a free account.
Similar topics
by: lawrence |
last post by:
I'm not sure how this is normally done, on a large site, perhaps one
running Phorum. Occassionally a thread will have hundreds of entries,
perhaps a meg or two worth of data. You won't necessarily...
|
by: Mark D. Anderson |
last post by:
About a month ago Richard Cornford did an interesting analysis of a
memory leak
in jscript (internet explorer) when there are "circular" references
between
DOM objects and (real) jscript objects:...
|
by: Bikash |
last post by:
Hello,
I am a specific problem in exception handling. The code snippets is
attached below.
void f()
{
char *ptr = new char(20);
throw 2;
}
|
by: Ian |
last post by:
I have and Access 97 DB that prints a report that has many pages, sometime
about 800-1000 page, each page contains a colour picture along with text
boxes.
The pictures are displayed on the...
|
by: boss_bhat |
last post by:
Hi all ,
I am beginner to C programming. I have a defined astructure like the
following, and i am using aliases for the different data types in the
structure,
typedef struct _NAME_INFO {...
|
by: Giovanni Boschi |
last post by:
We have found a memory leak when using a COM library with a C# application.
The leak appears only if the C# application is compiled with the /optimize
flag. It goes away when the C# application is...
|
by: syang8 |
last post by:
hi, folks,
I use Kdevelop to build some scientific simulation on Linux. If I set
the size of an array N = 8000, the program works fine. However, if I
set the array N some number greater than...
|
by: frederic.pica |
last post by:
Greets,
I've some troubles getting my memory freed by python, how can I force
it to release the memory ?
I've tried del and gc.collect() with no success.
Here is a code sample, parsing an XML...
|
by: George2 |
last post by:
Hello everyone,
Should I delete memory pointed by pointer a if there is bad_alloc when
allocating memory in memory pointed by pointer b? I am not sure
whether there will be memory leak if I do...
|
by: George2 |
last post by:
Hello everyone,
Such code segment is used to check whether function call or exception-
handling mechanism runs out of memory first (written by Bjarne),
void perverted()
{
try{
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
| |