Righty,
1: Is there a standard library that contain matrices and complex numbers. I
need to find eigen values of a 3x3 matrix.
2: Is there a way of getting the pointer to the start of an array from the
data stored in a std vector. I load loads of floats into a vector at the
moment to store vertex infomration for openGL, but to render them, I need to
pass a pointer to the beginning of the array to OpenGL, not a vector. At the
moment I'm just compying them into another array, but this seems like a bit
of a waste:
vector<float> vertices;
//Copy data into 'vertices'
Then before rendering I have to :
float* pVertexArray = new float[vertices.size()];
for(int i=0;i< vertices.size() ;i++) pVertexArray[i] = vertices[i];
But this seems silly!
Thanks Mike. 11 1554
"Michael" <sl***********@ hotmail.com> wrote in message
news:c7******** **@hercules.bti nternet.com... Righty,
1: Is there a standard library that contain matrices and complex numbers.
I need to find eigen values of a 3x3 matrix.
There are complex numbers in the header file <complex>
std::complex<do uble> c(1.0, 2.0);
std::complex<do uble> d = c*c;
etc.
There are no matrices as such. But you have a lot of options. You could
write a simple class that does all you need (I think that would be best). Or
you could use a vector of vectors. Of you could use valarray. 2: Is there a way of getting the pointer to the start of an array from
the data stored in a std vector.
Yes.
I load loads of floats into a vector at the moment to store vertex infomration for openGL, but to render them, I need
to pass a pointer to the beginning of the array to OpenGL, not a vector. At
the moment I'm just compying them into another array, but this seems like a
bit of a waste:
vector<float> vertices;
//Copy data into 'vertices'
Then before rendering I have to : float* pVertexArray = new float[vertices.size()]; for(int i=0;i< vertices.size() ;i++) pVertexArray[i] = vertices[i];
But this seems silly!
Right, just do this
some_function(& vectices[0]);
john
Michael wrote: Righty,
1: Is there a standard library that contain matrices
No, but there are plenty of third-party libraries available, many of
them open source. Try Google.
and complex numbers.
#include <complex>
I need to find eigen values of a 3x3 matrix.
2: Is there a way of getting the pointer to the start of an array from the data stored in a std vector.
&v[0]; // Not sure the standard mandates this, but I think there's a DR.
"Michael" <sl***********@ hotmail.com> wrote in message
news:c7******** **@hercules.bti nternet.com... Righty,
1: Is there a standard library that contain matrices and complex numbers. I need to find eigen values of a 3x3 matrix.
There is std::complex class (#include <complex>)
No class as such for matrices but you could take a look at valarray.
2: Is there a way of getting the pointer to the start of an array from the data stored in a std vector. I load loads of floats into a vector at the moment to store vertex infomration for openGL, but to render them, I need to pass a pointer to the beginning of the array to OpenGL, not a vector. At the moment I'm just compying them into another array, but this seems like a bit of a waste:
vector<float> vertices;
//Copy data into 'vertices'
Then before rendering I have to : float* pVertexArray = new float[vertices.size()]; for(int i=0;i< vertices.size() ;i++) pVertexArray[i] = vertices[i];
&vec[0] will give you the pointer to the first element.
-Sharad
Jeff Schwab wrote: Michael wrote:
Is there a way of getting the pointer to the start of an array from the data stored in a std vector.
&v[0]; // Not sure the standard mandates this, but I think there's a DR.
OK, it's (23.2.4.1) in the 2003 normative document.
Guys does this not violate the idea of encapsulation, you are making
assumptions about the implmentation that the data is stored contiguosly and
tightly packed?? Or is it just OK cos thats what the vector class is defined
as?
Mike
"Sharad Kala" <no************ *****@yahoo.com > wrote in message
news:c7******** ****@ID-221354.news.uni-berlin.de... "Michael" <sl***********@ hotmail.com> wrote in message news:c7******** **@hercules.bti nternet.com... Righty,
1: Is there a standard library that contain matrices and complex
numbers. I need to find eigen values of a 3x3 matrix.
There is std::complex class (#include <complex>) No class as such for matrices but you could take a look at valarray.
2: Is there a way of getting the pointer to the start of an array from
the data stored in a std vector. I load loads of floats into a vector at the moment to store vertex infomration for openGL, but to render them, I
need to pass a pointer to the beginning of the array to OpenGL, not a vector. At
the moment I'm just compying them into another array, but this seems like a
bit of a waste:
vector<float> vertices;
//Copy data into 'vertices'
Then before rendering I have to : float* pVertexArray = new float[vertices.size()]; for(int i=0;i< vertices.size() ;i++) pVertexArray[i] = vertices[i];
&vec[0] will give you the pointer to the first element.
-Sharad
"Michael" <sl***********@ hotmail.com> wrote in message
news:c7******** **@hercules.bti nternet.com... Guys does this not violate the idea of encapsulation, you are making assumptions about the implmentation that the data is stored contiguosly
and tightly packed?? Or is it just OK cos thats what the vector class is
defined as?
The standard guarantees that the data is stored contiguously.
john
"John Harrison" <jo************ *@hotmail.com> wrote in message
news:c759t5$ilk h5$1@ID- "Michael" <sl***********@ hotmail.com> wrote in message
I need to pass a pointer to the beginning of the array to OpenGL, not a vector
some_function(& vectices[0]);
This will fail for a vector of zero elements. If you know for certain
you'll have data, fine. Otherwise try
some_function(v ectices.size() ? &vectices[0] : NULL);
Siemel Naran wrote: "John Harrison" <jo************ *@hotmail.com> wrote in message news:c759t5$ilk h5$1@ID-
"Michael" <sl***********@ hotmail.com> wrote in message
I need to pass a pointer to the beginning of the array to OpenGL, not a vector
some_function (&vectices[0]);
This will fail for a vector of zero elements. If you know for certain you'll have data, fine. Otherwise try
some_function(v ectices.size() ? &vectices[0] : NULL);
Right-o. Another special case (other than an empty vector) is a
specialization like std::vector<boo l>. I'm not sure what happens in
that case.
"Michael" <sl***********@ hotmail.com> wrote in message
news:c7******** **@hercules.bti nternet.com... Guys does this not violate the idea of encapsulation, you are making assumptions about the implmentation that the data is stored contiguosly and tightly packed?? Or is it just OK cos thats what the vector class is defined as?
The 2003 "technical corrigendum" 23.2.4[1] says "The elements of a vector are
stored contiguously". This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Steven T. Hatton |
last post by:
Should I be able to forward declare something from a namespace different
from the current one? For example the following code compiles:
//testdriver.hpp
#ifndef TESTDRIVER_HPP
#define TESTDRIVER_HPP
#include <ostream>
namespace ns_testdriver{
using std::ostream;
|
by: John Gabriele |
last post by:
I'm hoping someone can please help me remember the C++ rule: When
you're writing a header file for a class (say, some_namespace::Bar),
and that class makes use of another class (some_namespace::Foo),
-------------------------------- snip --------------------------------
#ifndef GUARD_Foo_HPP
#define GUARD_Foo_HPP
namespace some_namespace {
|
by: Todd Huish |
last post by:
I have noticed something disturbing when retrieving datasets over a
relatively slow line (multiple T1). I am looking at about 25 seconds to
retrieve 500 rows via a php-odbc link. This same select from the cli is
for all intents practicaly instantaneous. After much research I discovered
that PHP by default uses a dynamic cursor type which can be quite a bit
slower than a forward only cursor. BTW I have been searching forward
only/read...
|
by: doodoosy |
last post by:
I'd like to insert an activeX control within a straight C program
|
by: Brad |
last post by:
I created a base page class which sets a response filter and the filter
injects additional html into the response output stream. The filter works
fine and everything works as expected except for the following quirk:
When I navigate my browser to another url (a link in the page, a browser
favorite...it doesn't mater) and then use the browsers (IE 6) Back or
Forward buttons to go back to my filtered page the additional html I had
added...
| |
by: aj |
last post by:
DB2 LUW v8.2 FP 14 RHAS 2.1
I have a DB2 online DB backup that was done w/ the INCLUDE LOGS
option. I am interested in restoring that backup, and rolling
forward ONLY the logs contained in the backup and no more, then
bringing the DB online.
I do not want to use a userexit to try and retrieve additional
logs - I only want to roll forward the logs in the backup. (In
case you haven't guessed, I am restoring a test version of my
|
by: JamC |
last post by:
Hi I have a poker program...
My code for Pair, 2 pair etc work, except when I code for a straight hand
When I separate the sort function like below I can get it...
public void straight()
{
int locations = new int, z = 0;
for ( int y = 0; y < numbers.length; y++ )
|
by: RedLars |
last post by:
Need some help with a couple of questions. Previously I have seen this
declaration;
struct Student
{
int age;
char name;
};
and this definition of an object;
struct Student stud;
|
by: Markus Dehmann |
last post by:
I need a Singleton for general program options so that all classes can
access it.
I use the code below (adapted from the Wikipedia singleton example).
But the problem is if I change one variable in it, all my classes have
to re-compile. But I am planning to add more options often during
development. I tried to solve it through a forward declaration "class
Opts;", but didn't succeed because Opts::instance() results in an
error message...
|
by: saraphen |
last post by:
I have a website option to send questions to a certain email. In that
email account I want to forward the website questions to a list of
people defined in a group. How do I accomplish this? Is there a
better way to do this?
Sarah
|
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...
| |
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: 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();...
|
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?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |