vector

Recommendations for C++ 3d vector/matrix library with targeted camera

I am writing a very simple 3d particle software rendering system, but I am only really interested in coding the particle system and the rasterizer, so what I am looking for, is the easiest way to go from 3d particle coordinates, through camera, to screen coordinates, but with features like variable FOV, and targeted (look at) camera. An...

Where is this code dereferencing an invalid iterator? (C++)

I have a loop for(aI = antiviral_data.begin(); aI != antiviral_data.end();) { for(vI = viral_data.begin(); vI != viral_data.end();) { if((*aI)->x == (*vI)->x && (*aI)->y == (*vI)->y) { vI = viral_data.erase(vI); aI = antiviral_data.erase(aI); } else { vI++; aI++; } } } But when ever antiviral_data contains a...

Why is it better to use '!=" than '<' in a vector loop? (C++)

Why is it better to use '!=" than '<' in a vector loop? I just can't see the difference. ...

How to erase element from std::vector<> by index?

If I have a std::vector and I want to delete the x'th element how to do it? std::vector<int> vec; vec.push_back(6); vec.push_back(-17); vec.push_back(12); vec.erase(???); Please help! ...

Get the 1-norm of a vector in Python

How can I calculate the 1-norm of the difference of two vectors, ||a - b||_1 = sum(|a_i - b_i|) in Python? a = [1,2,3,4] b = [2,3,4,5] ||a - b||_1 = 4 ...

How to sort an object std::vector by its float value

I have a C++ std::vector denoted as: std::vector<GameObject*> vectorToSort; Each object in vectorToSort contains a float parameter which is returned by calling "DistanceFromCamera()": vectorToSort.at(position)->DistanceFromCamera(); I wish to sort the vector by this float parameter however std::sort does not appear to be able to do...

Memory leak (sort of) with a static std::vector

I have a static std::vector in a class. When I use Microsoft's memory leak detection tools: _CrtMemState state; _CrtMemCheckpoint( & state); _CrtMemDumpAllObjectsSince( & state ); it reports a leak after I insert stuff into the vector. This makes sense to me because new space is allocated when something is inserted into the vector. ...

Benefit of slist over vector?

What I need is just a dynamically growing array. I don't need random access, and I always insert to the end and read it from the beginning to the end. slist seems to be the first choice, because it provides just enough of what I need. However, I can't tell what benefit I get by using slist instead of vector. Besides, several materials I...

Vector rotation by vector

Possible Duplicate: C++: Rotating a vector around a certain point I have 3 points and a vector. I need to rotate the vector around point B by the angle ABC. How would I do this? ...

What is the difference between accesing vector elements using an iterator vs an index?

What advantages are there in accessing vector elements using an iterator vs an index? ...

Why can't I make a vector of references?

When I do this: std::vector<int> hello; Everything works great. However, when I make it a vector instead: std::vector<int &> hello; I get horrible errors like "error C2528: 'pointer' : pointer to reference is illegal". I want to put a bunch of references to structs into a vector, so that I don't have to meddle with pointers. Why i...

POD low dimensional vector in boost

I'm looking for POD low dimension vectors (2,3 and 4D let say) with all the necessary arithmetic niceties (operator +, - and so on). POD low dimension matrices would be great as well. boost::ublas vectors are not POD, there's a pointer indirection somewhere (vector are resizeable). Can I find that anywhere in boost? Using boost::array ...

C++: Assigning values to non-continuous indexes in vectors?

If I want to declare a vector of unknown size, then assign values to index 5, index 10, index 1, index 100, in that order. Is it easily doable in a vector? It seems there's no easy way. Cause if I initialize a vector without a size, then I can't access index 5 without first allocating memory for it by doing resize() or five push_back()'...

Can AS3 vectors be declared with a type reference?

Instead of this: var v:Vector.<String> = new Vector.<String>(); is there any way to do something like this? var myType:Class = String; var v:Vector.<myType> = new Vector.<myType>(); Obviously that doesn't work as written, but hopefully you get the idea. ...

Is there a library that can do raster to vector conversion, for the iPhone?

I am trying to take an image and extract hand written text so that it can be read easily and zoomed in on. I would like to convert the text to vector paths. I am not aware of any libraries that would make this as painless as possible. Any help is greatly appreciated. Examples are nice too :) ...

What is a data structure that has O(1) for append, prepend, and retrieve element at any location?

I'm looking for Java solution but any general answer is also OK. Vector/ArrayList is O(1) for append and retrieve, but O(n) for prepend. LinkedList (in Java implemented as doubly-linked-list) is O(1) for append and prepend, but O(n) for retrieval. Deque (ArrayDeque) is O(1) for everything above but cannot retrieve element at arbitrary...

How to erase & delete pointers to objects stored in a vector?

I have a vector that stores pointers to many objects instantiated dynamically, and I'm trying to iterate through the vector and remove certain elements (remove from vector and destroy object), but I'm having trouble. Here's what it looks like: vector<Entity*> Entities; /* Fill vector here */ vector<Entity*>::iterator it; ...

Efficient comparison of 100.000 vectors

I save 100.000 Vectors of in a database. Each vector has a dimension 60. (int vector[60]) Then I take one and want present vectors to the user in order of decreasing similarity to the chosen one. I use Tanimoto Classifier to compare 2 vectors: Is there any methods to avoid doing through all entries in the database? One more thing! ...

BLAS daxpy and dcopy when inc=1, are they any faster than just using a(:,t) = b(:,t)?

Well the title says it, I'm doing following kind of operations in Fortran: a(:,t) = b(:,t) c(:,t) = x(i,t)*d(:,t) Is there any benefits of using daxpy and dcopy subroutines from BLAS in this case where inc=1? ...

Stroustrup swan book Vector Problem

I'm using Stroustrup's swan book. I have run into a problem getting output from a vector. I followed the text example from sec. 4.6.3 on page 121. I managed to get the source compiled and am able to execute it. After typing in a list of whitespace separated words, the program hangs and does not list the elements of the vector as it shoul...