vector

In R, how do I set the first values of a long vector to the values of a shorter one?

In R, how can I overwrite the first values of a long vector with values obtained from a file, where the file contains possibly fewer values? Example: # fill with n=100 values vec1 <- runif(100) # read m values, where m <= n vec2 <- scan("myfile", sep="\n") # now want to set the first m values of vec1 # to the values in vec2 I coul...

Very general question about the implementation of vectors, vertices, edges, rays, lines & line segments.

This is just a LARGE generalized question regarding rays (and/or line segments or edges etc) and their place in a software rendered 3d engine that is/not performing raytracing operations. I'm learning the basics and I'm the first to admit that I don't know much about this stuff so please be kind. :) OK, I wondered why a parametrized lin...

Vector Quantization in Speech Processing Explanation

Hi all, I'm having trouble determining from this research paper exactly how I can reproduce the Standard Vector Quantization algorithm to determine the language of an unidentified speech input, based on a training set of data. Here's some basic info: Abstract info Language recognition (e.g. Japanese, English, German, etc) using acoustic...

Objective-C equivalent of Java Vector?

What is the equivalent for Vector's of Java in Objective-C? ...

XNA 2D vector angles - what's the correct way to calculate ?

what is in XNA in 2D the standard way vector angles work ? 0 degrees points right, 90 points up, 180 left, 270 down ? What are the 'standard' implementations of float VectortoAngle(Vector2 vec) and Vector2 AngleToVector(float angle) so that VectortoAngle(AngleToVector(PI)) == PI ? ...

Code golf: c++ deque->vector

I'm coding in C++ What is the shortest function of: template<T> std::vector<T> make_copy(const deque<T>& d) { // your code here } ? ...

Vector vs. Data frame in R

What is the difference between a vector and a data frame in R? Under what circumstances vectors should be converted to data frames? ...

vector reserve c++

I have a very large multidimensional vector that changes in size all the time. Is there any point to use the vector.reserve() function when I only know a good approximation of the sizes. So basically I have a vector A[256*256][x][y] where x goes from 0 to 50 for every iteration in the program and then back to 0 again. The y values ca...

WPF - Get the angle in degrees of a Vector3D as viewed from above

I'm working with a 3D that has a property of type Vector3D called FrontDirection. This object is rotated as follows: var rotate = new AxisAngleRotation3D(new Vector3D(0, 1, 0), deltaAngleInDegrees); var transform = new RotateTransform3D(rotate); my3DObject.FrontDirection = transform.Transform(my3DObject.FrontDirection); After some a...

C++ Two Dimensional std::vector best practices

I am building an app that needs to have support for two dimensional arrays to hold a grid of data. I have a class Map that contains a 2d grid of data. I want to use vectors rather than arrays, and I was wondering what the best practices were for using 2d vectors. Should I have a vector of vectors of MapCells? or should it be a vector of ...

How to use Vector as DataSource ?

Hi, I wanna use this vector as DataSource for my Jtable.There is 4 Column here (ADI,SOYADI,BABA ADI, ANA ADI). ResultSet is adding every row to vector named _kisivector.This is my DataSource.But i dont wanna get whole records at start.I wanna get only 5 records from this vector.Than there will be 2 button , back and forward.When i click...

How to get 2 random (different) elements from a c++ vector

I would like to get 2 random different elements from an std::vector. How can I do this so that: It is fast (it is done thousands of times in my algorithm) It is elegant The elements selection is really uniformly distributed ...

Strange vector initialization issue

I recently debugged a strange C++ problem, in which a newly declared vector somehow had a size of 477218589. Here's the context: struct Triangle { Point3 a,b,c; Triangle(Point3 x, Point3 y, Point3 z) : a(x), b(y), c(z) {} Vector3 flat_normal() { return (a-c)^(b-c); } }; vector<Triangle> triangles; Calling triangles.size()...

Can I write the contents of vector<bool> to a stream directly from the internal buffer?

I know vector< bool > is "evil", and dynamic_bitset is preferred (bitset is not suitable) but I am using C++ Builder 6 and I don't really want to pursue the Boost route for such an old version. I tried : int RecordLen = 1; int NoBits = 8; std::ofstream Binary( FileNameBinary ); vector< bool > CaseBits( NoBits, 0 ); Binary.write( ( const...

STL vector taking up too much memory

Im using a STL vector in my SDL program. and it looks like this: vector< Bullet * > vec; this makes a vector that can contain pointers to Bullet objects. when i run my program i only add one item at a time using: vec.push_back( new_bullet ); (new_bullet is a pointer to a "new" Bullet object. then in a following function i erase an object...

3d geometry: how to align an object to a vector

hello, i have an object in 3d space that i want to align according to a vector. i already got the Y-rotation out by doing an atan2 on the x and z component of the vector. but i would also like to have an X-rotation to make the object look downwards or upwards. imagine a plane that does it's pitch yaw roll, just without the roll. i am...

std::vector, std::map and memory issues

I am writing code that inserts rows from a database into a vector. The vectors are then stored in a std::map. This architecture allows me to logically partition the datasets (vectors), based on the map key. In my code, I will be retrieving a dataset (i.e. vector) from the std::map, adding/removing rows to it or performing some other log...

C++: How to access a class function inside another class?

I am learning how to work with std::vector and want to access its values and functions. I have a vector object inside another object called spectrum. Now when I try to determine the capacity of the vector using .capacity it works fine if I just declare the vector. But when I declare the vector inside another object, I get syntax errors. ...

C++: How to make constructor for multidimensional vector?

I want to create two and three dimensional vectors using a constructor in a class. However, I do not know how for multidimensional vectors. One dimensional works: class One{ public: vector < float > myvector; One(int length) : myvector(length){} }; Two dimensional does not work: class Two{ public: v...

How to efficiently rotate and translate a plane in 3D

I have a plane defined by a normal (n) and a distance (d) (from the origin). I would like to transform it into a new system. The long way is like this: 1) multiply distance (d) with normal (n) resulting in a a vector (p) 2) rotate (R) and translate (v) the vector (p) to get (p') 3) normalize (p') to get the normal 4) use another algorith...