vector

How do I create a regularly-spaced array of values in MATLAB?

How do I make an array that's defined with a start point, an end point, and a total array size? Something like an array that goes from 1 to 10 that's 20 elements long. For example, the array could look something like: 1 1.5 2 2.5 3 3.5 ... ...

How to set a default parameter for a vector <string> for use in a default constructor within a class?

For example, a class named Table, with its constructor being: Table(string name="", vector <string> mods); How would I initialize the vector to be empty? Edit: Forgot to mention this was C++. ...

get similarity score between two document termfreqvectors

Hi I would like to extract similarity score between two document termfreqvectors. I checked that if i submit the first one as a query and look the second in the result set, I cannot have the precise score that lucene gives for these two vectors? any help? ...

vectors vs. vector graphics

What (if any) is the relationship between vectors used in programming languages (e.g. arrays) and vector graphics? Why do they share the term vector? Does it represent some analogous aspect of their nature or is it coincidence? When thinking about it, a bitmap image would fit the term vector graphic better since it's represented by an...

ActionScript 3 Vector.<T> VS. Array

This question if a bit off topic, I just wanted feedback from most ActionScript/Flex developers out there. So would you use a Vector. rather than an Array when you're expecting a collection of the same "type" of objects (and publishing for fp10) Let me clear that out : I'm defining a method in a class that expects one parameter of ty...

Compare Two Vectors (Java)

Hi Currently I have two larger vectors of 50+ strings I want to be able to compare these two Vectors and work out how similar they are. I think I need to use Cosine similarity? Does anyone know of any methods that take in two Java Vectors and gives a value between 0 and 1 as to how similar they are? Thanks Phil ...

global vector C++

Is it possible to have a vector as a global variable is C++? Like this: class system {...}; vector<system> systems; when I try to compile this I get an error. The compiler I'm using is gcc and I'm compiling as C++. ...

Avoid making copies with vectors of vectors

I want to be able to have a vector of vectors of some type such as: vector<vector<MyStruct> > vecOfVec; I then create a vector of MyStruct, and populate it. vector<MyStruct> someStructs; // Populate it with data Then finally add someStructs to vecOfVec; vecOfVec.push_back(someStructs); What I want to do is avoid having the copy ...

Openlayers vector layer

I want to have a vector layer of the world, which shows the country borders, states and their names in English. Is there a layer that exists that I can control the colours? Cloudmade doesn't let me quite do this, nor does openstreetmap and a bunch of others. I'm thinking I might need to create a raster image and overlay that except I do...

resize versus push_back in std::vector : does it avoid an unnecessary copy assignment?

Hello people. When invoking the method push_back from std::vector, its size is incremented by one, implying in the creation of a new instance, and then the parameter you pass will be copied into this recently created element, right? Example: myVector.push_back(MyVectorElement()); Well then, if I want to increase the size of the vecto...

array vs vector vs list

I am maintaining a fixed-length table of 10 entries. Each item is a structure of like 4 fields. There will be insert, update and delete operations, specified by numeric position. I am wondering which is the best data structure to use to maintain this table of information: array - insert/delete takes linear time due to shifting; update ...

Framework for building visually rich desktop applications?

Hi, I've started building an app with Flex/Air but am getting sick of it's clunkyness. The app that I'm building has similar behaviour to Prezi (www.prezi.com) but in a completely different field. I'm looking for something on the desktop which has flex like capabilities, such as drawing vectors then zooming in/out, rotating etc, gui w...

C++ dereference vector pointer to access element

Hi! If i have in C++ a pointer to a vector: vector<int>* vecPtr; And i'd like to access an element of the vector, then i can do this by dereferncing the vector: int a = (*vecPtr)[i]; but will this dereferencing actually create a copy of my vector on the stack? let's say the vector stores 10000 ints, will by dereferencing the vecPt...

Replacement for vector accepting non standard constructable and not assignable types

I have a class test which isn't standard constructable nor assignable due to certain reasons. However it is copy constructable - on may say it behaves a bit like a reference. Unfortunately I needed a dynamic array of these elements and realized that vector<test> isn't the right choice because the elements of a vector must be standard co...

std::vector of known sequences

I'm trying to learn C++ by doing everything "the C++ way". I'm writing a program where I have all of these known values (at compile time). Here is my problem: In my constructor I want to check to see if a passed value(an int) is one of 2,4,8,16 or 32 and throw an error elsewise. I've though about: making a C style array or ints cre...

How to calculate end points of perpendicular line segments?

I know the end points of a line segment and the distance/size of the perpendicular end caps I'd like to create but I need to calcuate the end points of the perpendicular line. I've been banging my head against the wall using either 45-45-90 triangles and dot products but I just can't seem to make it come together. I know the points in b...

Converting a matlab matrix to a vector

I want to get a vector of elements of a Matlab matrix at predefined locations. For example, I have the following >> i = [1,2,3]; >> j = [1,3,4]; >> A = [1,2,3,4; 5,6,7,8; 9,10,11,12; 13,14,15,16] A = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 I want a vector that will give me ...

C++ Vector vs Array (Time)

I have got here two programs with me, both are doing exactly the same task. They are just setting an boolean array / vector to the value true. The program using vector takes 27 seconds to run whereas the program involving array with 5 times greater size takes less than 1 s. I would like to know the exact reason as to why there is such a ...

Vector class in a Flex Library Project

i seem to be having some problems with the Vector class in actionscript 3 in a Flex Project or an ActionScript Project it is possible to do this var v:Vector.<String>; But when i do the same thing in a Flex Library Project (to create an SWC) then i get the following error on that line of code 1046: Type was not found or was not a com...

Pointers wanted: How to display image grids / plots with superimposed vector data?

A few years ago I participated in an MFC VC++ project to draw a grid of JPG or TIFF images and superimpose them with vector data of lines and shapes. Something like a plot of 4X6 images of areal photos and lines showing distances and directions between user defined points. What are good ways of doing the same nova days? Would the Silv...