I'm taking in data from multiple files that represents complex numbers
for charateristics of different elements. I begin with arrays of
doubles and interpolate to get standard values in real and imaginary
portions. To this end I have some dynamic arrays of doubles to hold
the standardized individual rael and imaginary parts.
double *ANreal, *ANimag, *BNreal, *BNimag, *CNreal, *CNimag;
ANreal = new double[num];
ANimag = new double[num];
etc....
Later I want to combine the seperate portions into the complex class.
complex<double> *AN, *BN, *CN;
AN = new complex<double>[count];
etc...
AN[i].real = ANreal[k];
AN[i].imag = ANreal[k];
etc...
but this is not working. I get an error that forming
apointer-to-member requires use the address-of operator (''.), and that
"=" overloaded function as left operand. I do not want to use vectors,
I want to do it using this paradigm so I can better learn its
intricacies. When I use the -> operator in place of the .dot i am told
that std::complex<do uble> does not have that overloaded member
operator, and that left of ->real must point to class/struct. If I
throw either a * or & out front I get illegal operaton on bound member
function.
Later I will use an array of pointers to these arrays of class objects
complex<double> **BigN[4] = {*AN, *CN, *BN, *CN};
so I can do the actual caclulations that this all builds up to, using a
loop within a loop, so that I can go through the first element in each
array in the order the arrays are listed in BigN, then go to the next
element in each array in that order. Something like:
for(int i = 0; i<count; i++)
{
for(int j = 0; j<3; j++)
{
result[j]=BigN[j] * BigN[j+1] etc...;
}
*AN++;
*BN++;
*CN++;
}
So the main question I have here is how to set the real and imaginary
parts of the objects in the array of class complex<double> .
thanks in advance
James 2 2924
* jc******@gmail. com: complex<double> *AN, *BN, *CN;
Tip 1: You'll get fewer problems with macros if you refrain from using
all uppercase names for non-macros.
Tip 2: You'll get fewer problems if you refrain from using globals.
Tip 3: This is much much easier using std::vector.
AN = new complex<double>[count]; etc...
AN[i].real = ANreal[k]; AN[i].imag = ANreal[k]; etc...
but this is not working. I get an error that forming apointer-to-member requires use the address-of operator (''.)
'real' and 'imag' are not member variables, they're member functions
(please do read the documentation).
Try
AN[i] = std::complex( ANReal[i], ANImag[i] );
I'm assuming that using ANReal also for the imag part was a typo.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail? jc******@gmail. com wrote: I'm taking in data from multiple files that represents complex numbers for charateristics of different elements. I begin with arrays of doubles and interpolate to get standard values in real and imaginary portions. To this end I have some dynamic arrays of doubles to hold the standardized individual rael and imaginary parts.
double *ANreal, *ANimag, *BNreal, *BNimag, *CNreal, *CNimag;
ANreal = new double[num]; ANimag = new double[num]; etc....
Later I want to combine the seperate portions into the complex class.
complex<double> *AN, *BN, *CN;
AN = new complex<double>[count]; etc...
AN[i].real = ANreal[k]; AN[i].imag = ANreal[k];
Both 'real' and 'imag' are the names of the member _functions_, not of data
members. To set the real part (and the imaginary part) you need to
construct
a temporary 'complex' value and assign from it:
AN[i] = complex(ANreal[k], ANimag[n]);
etc...
but this is not working. [..]
Of course it isn't. Do you ever RTFM? I am sure it describes available
interface for the 'complex' template.
So the main question I have here is how to set the real and imaginary parts of the objects in the array of class complex<double> .
See above.
V
--
Please remove capital As from my address when replying by mail This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Banaticus Bart |
last post by:
I wrote an abstract base class from which I've derived a few other
classes. I'd like to create a base class array where each element is
an instance of a derived object. I can create a base class pointer
which points to an instance of a derived class, but when I pass that
base class pointer into a function, it can't access the derived
object's public functions. Although, the base class pointer does call
the appropriate virtual function...
|
by: justanotherguy63 |
last post by:
Hi,
I am designing an application where to preserve the hierachy and for
code substitability, I need to pass an array of derived class object in
place of an array of base class object. Since I am using vector
class(STL), the compiler does not allow me to do this.
I do realize there is a pitfall in this approach(size of arrays not
matching etc), but I wonder how to get around this problem. I have a
class hierachy with abstract base...
|
by: sneill |
last post by:
How is it possible to take the value of a variable (in this case,
MODE_CREATE, MODE_UPDATE, etc) and use that as an object property name?
In the following example I want 'oIcon' object to have the properties:
mode1, mode2, and mode3.
This seems simple but I can't quite figure it out...
Any ideas anyone?
|
by: Gerald |
last post by:
I have a problem with an array of pointers.
In a program I'm writing, I have to read a file, containing thousands
of short lines. The content of another file will be compared against
each line later on. Before that happens there has been a problem that
causes a crash of the program.
This is a little program "test.exe" I wrote to test what happens.
compiler: mingw 3.1.01 for win32 command line
|
by: Jack Addington |
last post by:
Quite new to C# but I am getting quite confused with Array's and ArrayLists.
This is probably the same old iteration of a basic question but I can't seem
to find a clear answer/example of this case.
Basically I want a container that points to a set objects that I can then
interate through to group together a set of methods in a transaction. The
number of objects is unknown at compile time. I can't seem to come up with
a dynamic array...
| |
by: lemonade |
last post by:
Hello!
Can someone explain to me the difference between dynamic
array of pointers vs dynamic array of objects by giving a
real life example. Following is the code that I am using
for dynamic array of objects. I am skipping initialization
and other member functions.
class Inventory {
Item *itemList;
int idx, count, size;
|
by: tomerdr |
last post by:
Hi,
I have been asked to create a dynamic template array as an exercise.
the array should be used as follows:
CDynamicArray<City*arr; or CDynamicArray<Streetarr;
It also need to support operator << for streaming the content.
(each class also support operator << )
My question is how do i deal with the fact that the array can contains
|
by: subramanian100in |
last post by:
Suppose
class Base
{
public:
virtual ~Test() { ... }
// ...
};
class Derived : public Base
|
by: WaterWalk |
last post by:
Hello. When I consult the ISO C++ standard, I notice that in
paragraph 3.6.2.1, the standard states:
"Objects with static storage duration shall be zero-initialized before
any other initialization takes place."
Does this mean all non-local objects will be zero-initialized before
they are initialized by their initializers(if they have)? For example:
int g_var = 3;
int main() {}
|
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...
|
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,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |