473,779 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with double matrix in vc++ Express edition

Hi, I've got a problem with this code.

I've got a double Matrix A and a vector b, initialized with

DoubleMatr A = new double*[3];
DoubleVect b = new double[3];

where DoubleMatr and DoubleVect are defined as

typedef double* DoubleVect;
typedef double** DoubleMatr;

then i pass the matrix and the vector to a function

void CreateSystemFro mPolygon(Polygo n *p, double *X, double *Y,
DoubleMatr A, DoubleVect b)
....
for ( int i = 0 ; i < 3 ; i++)
{
for (int j = 0 ; j < 3; j++)
{
A[i][j] = 0;
}

b[i] = 0.0;
}

A[0][0] = 1.0;
A[1][1] = 1.0;

b[0] = X[0];
b[1] = Y[0];
....

at runtime i watch the values of A[0][0] A[0][1] etc..
I see that the istruction A[0][0] = 1.0 modify A[0][0] but A[1][0] and
A[2][0] too.
Where is the problem?
Dec 20 '07 #1
4 1306
Nangi wrote:
Hi, I've got a problem with this code.

I've got a double Matrix A and a vector b, initialized with

DoubleMatr A = new double*[3];
DoubleVect b = new double[3];

where DoubleMatr and DoubleVect are defined as

typedef double* DoubleVect;
typedef double** DoubleMatr;

then i pass the matrix and the vector to a function

void CreateSystemFro mPolygon(Polygo n *p, double *X, double *Y,
DoubleMatr A, DoubleVect b)
...
for ( int i = 0 ; i < 3 ; i++)
{
for (int j = 0 ; j < 3; j++)
{
A[i][j] = 0;
}

b[i] = 0.0;
}

A[0][0] = 1.0;
A[1][1] = 1.0;

b[0] = X[0];
b[1] = Y[0];
...

at runtime i watch the values of A[0][0] A[0][1] etc..
I see that the istruction A[0][0] = 1.0 modify A[0][0] but A[1][0] and
A[2][0] too.
Where is the problem?
Nanji:

You have not defined a two-dimensional double array. You have just
defined an array of 3 double pointers. A[0], for example is a pointer to
double, but it is not pointing at anything. You need to do

A[0] = new double[3];
A[1] = new double[3];
A[2] = new double[3];

--
David Wilkinson
Visual C++ MVP
Dec 21 '07 #2
On 21 Dic, 03:39, David Wilkinson <no-re...@effisols. comwrote:
Nangi wrote:
Hi, I've got a problem with this code.
I've got a double Matrix A and a vector b, initialized with
* *DoubleMatr A = new double*[3];
* *DoubleVect b = new double[3];
where DoubleMatr and DoubleVect are defined as
typedef double* DoubleVect;
typedef double** DoubleMatr;
then i pass the matrix and the vector to a function
void CreateSystemFro mPolygon(Polygo n *p, double *X, double *Y,
DoubleMatr A, DoubleVect b)
...
* *for ( int i = 0 ; i < 3 ; i++)
* *{
* * * * * *for (int j = 0 ; j < 3; j++)
* * * * * *{
* * * * * * * * * *A[i][j] = 0;
* * * * * *}
* * * * * *b[i] = 0.0;
* *}
* *A[0][0] = 1.0;
* *A[1][1] = 1.0;
* *b[0] = X[0];
* *b[1] = Y[0];
...
at runtime i watch the values of A[0][0] A[0][1] etc..
I see that the istruction A[0][0] = 1.0 modify A[0][0] but A[1][0] and
A[2][0] too.
Where is the problem?

Nanji:

You have not defined a two-dimensional double array. You have just
defined an array of 3 double pointers. A[0], for example is a pointer to
double, but it is not pointing at anything. You need to do

A[0] = new double[3];
A[1] = new double[3];
A[2] = new double[3];

--
David Wilkinson
Visual C++ MVP- Nascondi testo tra virgolette -

- Mostra testo tra virgolette -
Sorry, I forgot to post this part of code..

for ( int i = 0 ; i < 3 ; i++ ) A[i] = new double[3];
Dec 21 '07 #3
On 21 Dic, 03:39, David Wilkinson <no-re...@effisols. comwrote:
Nangi wrote:
Hi, I've got a problem with this code.
I've got a double Matrix A and a vector b, initialized with
* *DoubleMatr A = new double*[3];
* *DoubleVect b = new double[3];
where DoubleMatr and DoubleVect are defined as
typedef double* DoubleVect;
typedef double** DoubleMatr;
then i pass the matrix and the vector to a function
void CreateSystemFro mPolygon(Polygo n *p, double *X, double *Y,
DoubleMatr A, DoubleVect b)
...
* *for ( int i = 0 ; i < 3 ; i++)
* *{
* * * * * *for (int j = 0 ; j < 3; j++)
* * * * * *{
* * * * * * * * * *A[i][j] = 0;
* * * * * *}
* * * * * *b[i] = 0.0;
* *}
* *A[0][0] = 1.0;
* *A[1][1] = 1.0;
* *b[0] = X[0];
* *b[1] = Y[0];
...
at runtime i watch the values of A[0][0] A[0][1] etc..
I see that the istruction A[0][0] = 1.0 modify A[0][0] but A[1][0] and
A[2][0] too.
Where is the problem?

Nanji:

You have not defined a two-dimensional double array. You have just
defined an array of 3 double pointers. A[0], for example is a pointer to
double, but it is not pointing at anything. You need to do

A[0] = new double[3];
A[1] = new double[3];
A[2] = new double[3];

--
David Wilkinson
Visual C++ MVP- Nascondi testo tra virgolette -

- Mostra testo tra virgolette -
I've tried to run same code in Borland C++ Builder 2006.
THERE IS NO ERROR!

IS THIS A VC++ 2008 BUG?
Dec 22 '07 #4
Nangi wrote:
On 21 Dic, 03:39, David Wilkinson <no-re...@effisols. comwrote:
>Nangi wrote:
>>Hi, I've got a problem with this code.
I've got a double Matrix A and a vector b, initialized with
� �DoubleMatr A = new double*[3];
� �DoubleVect b = new double[3];
where DoubleMatr and DoubleVect are defined as
typedef double* DoubleVect;
typedef double** DoubleMatr;
then i pass the matrix and the vector to a function
void CreateSystemFro mPolygon(Polygo n *p, double *X, double *Y,
DoubleMatr A, DoubleVect b)
...
� �for ( int i = 0 ; i < 3 ; i++)
� �{
� � � � � �for (int j = 0 ; j < 3; j++)
� � � � � �{
� � � � � � � � � �A[i][j] = 0;
� � � � � �}
� � � � � �b[i] = 0.0;
� �}
� �A[0][0] = 1.0;
� �A[1][1] = 1.0;
� �b[0] = X[0];
� �b[1] = Y[0];
...
at runtime i watch the values of A[0][0] A[0][1] etc..
I see that the istruction A[0][0] = 1.0 modify A[0][0] but A[1][0] and
A[2][0] too.
Where is the problem?
Nanji:

You have not defined a two-dimensional double array. You have just
defined an array of 3 double pointers. A[0], for example is a pointer to
double, but it is not pointing at anything. You need to do

A[0] = new double[3];
A[1] = new double[3];
A[2] = new double[3];

--
David Wilkinson
Visual C++ MVP- Nascondi testo tra virgolette -

- Mostra testo tra virgolette -

I've tried to run same code in Borland C++ Builder 2006.
THERE IS NO ERROR!

IS THIS A VC++ 2008 BUG?
Nanji:

Maybe the bug (if any) is in the debugger, not in the code generator.

--
David Wilkinson
Visual C++ MVP
Dec 22 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
1981
by: Bonj | last post by:
Hi I installed .NET 2005 express edition, and am about to unnistall it again because it can't seem to be able to even insert a resource file into a project. Can anyone tell me is this right? Should it be able to? I know it's express edition, and therefore limited functionality, but surely resources are quite fundamental? Also, once it's downloaded, is there any way of getting access to the fully downloaded file incase you want to...
12
1500
by: John Gabriel | last post by:
lThe compiler output report is seldom correct: Problems here involve not being able to generate an accurate compile report. There are so many problems and I am not on Microsoft's payroll. Neither do I plan to help them fix such a buggy product. The IDE closes down unexpectedly: For no reason at all, the IDE aborts (shuts down); prompts for permission to send an error report to Microsoft. Debug windows: There are problems with variables...
6
1909
by: John Dalberg | last post by:
I don't know how much Microsoft is planning to price Visual Web Developer Express Edition. I heard rumors from free to $100. In my opinion I think it should make it free. The reason is to attract as many people to .NET and ASP.NET. This includes people who are in the Linux world using free IDE's like Eclipse and the people who are thinking of switching from Windows to Linux because Linux and Linux tools are free. Even if MS prices it at...
2
1109
by: Vijay | last post by:
Can I write ASPX pages wtih VC# Express edition for windows? Will get a template, like New ASPX page? VJ
2
1051
by: Ralph | last post by:
Does anyone know how to obtain the VC++ 2005 Express Edition on a CD? I have been unable to download and create a viable CD from the Microsoft site. Either not holding my mouth right or I have the wrong software. Thanks, -ralph
2
1365
by: Schizoid Man | last post by:
Hi, I want to write some custom UDFs for Excel in C# and and build them into XLLs. However, I can't seem to check the Register for Com Interop box in the Express Edition of VC#. Is this a known limitation of VC# Express? Is there a way for me to still use the Express edition to build my functions?
3
3401
by: hsmit.home | last post by:
I spent way too much time on this and I must say, I was a little disgruntled with what has been posted on all the various Xalan C mailing lists. Everyone says there's a solution, but give next to no detail on how to achieve this "allusive" solution. Well I spent the better part of a day finally figuring it out the hard way, trial and error. Here's a list of steps to compile the Xalan C version 1.10.0 on Microsofts Visual C++ 2005...
9
1851
by: =?Utf-8?B?S3VlaXNoaW9uZyBUdQ==?= | last post by:
What is the difference between the regular VC++ edition and the VC++ express edition? If there is not too much difference in functionality, why the express edition is free?
2
2494
by: ChaosMageX | last post by:
I copied some code from a Mono 2.4 library to use in my own application. I'm getting a problem because one of the variable declarations involves the keyword "pinned" between the identifier and the instance name. public override unsafe void PutBytes(byte dest, int destIdx, double value) { base.Check(dest, destIdx, 8); byte* pinned numPtr = $(dest); long* numPtr2 = (long*) &value; *((long*) numPtr) = numPtr2; numPtr =...
0
9633
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10305
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10074
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9928
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.