Questions tagged [vector]

12347 questions
1

votes
1

answer
78

Views

Convert vector into matrix: New row when value > X

I have a question and I can't find any solution, My problem is, that i have a vector V (m x 1). V is imported data from excel and can differ in leangth. It contains sequences of numbers >7000 and sequences of numbers < 7000. The sequences also can differ in leangth. Now I want to copy all values tha...
Chris
1

votes
0

answer
267

Views

Compute a similarity coefficient (DICE) between many images using R

I'm looking for a way to compute the similarity index between 2 files, however, I have almost 100 files for comparing. In order to make the process easier, I've started with just 10 of them. I need to load both images as matrices (image and its ground truth) for applying the method for finding the s...
S4nD3r
1

votes
1

answer
35

Views

c++ char vector, deleting words with numbers in them plus whitespace after bad word

I think I'm pretty close to solving this but I get a bus error on one of the lines. I have a program that reads from a file that takes in all the words buy separating them into characters. Some words have digits or punctuations in them and the program is suppose to go throw and delete those words...
Zane Howcott
1

votes
1

answer
155

Views

How can I extrude a complex SVG in processing

I'm currently trying to extrude PShape that was created with an SVG file from Adobe Illustrator. My current approach + image is posted below: Create the base image shape Create a copy of the base image with z offset Connect each vertex from both shapes and make it a QUAD_STRIP PShape group = crea...
Dominic Cabral
1

votes
0

answer
123

Views

Best way to convert std::vector<StructInts> from/to numpy.ndarray in cython?

I'm using cython to wrap a c++ library. A data structure to be wrapped in c++ side is: struct StructInts { int a; int b; int c; }; typedef std::vector VectorTris; I'm hope for using numpy.ndarray as an interface in cython side(because the data source is numpy.ndarray), with imagined functions like:...
user9410891
1

votes
1

answer
32

Views

How can I use a for loop to omit entries from a vector? [duplicate]

This question already has an answer here: How to delete an element at a time from a vector while retaining the others? 4 answers Here is my initial thought, vector
Dan
1

votes
1

answer
376

Views

Leap Motion - Angle of proximal bone to metacarpal (side to side movement)

I am trying to get the angle between the bones, such as the metacarpal bone and the proximal bone (angle of moving the finger side to side, for example the angle when your index finger is as close to your thumb as you can move it and then the angle when your index finger is as close to your middle f...
user7856951
1

votes
1

answer
993

Views

Unity3D angle between vectors/directions on specific axis

I have two directions and i am trying to calculate the angle on a specific axis. The object from which the directions are derived is not a static object so i'm struggling to get my head round the maths to work out what i need to do. FYI, I have the start and end points that i have used to calculate...
user7856951
1

votes
0

answer
46

Views

Pyspark save data frame as csv with many vector columns

I have a pyspark data frame with hundreds of columns that are one-hot encoded (in vector format). I need to save this data frame, but I can’t save it to a csv since csv doesn’t accept vector formatted columns. What is the best way to save this data frame? Should I loop over all columns and con...
gannawag
1

votes
1

answer
190

Views

vectorising the eval(parse(text)) function

I have a problem in R with the funciont eval.parent... Let's take a data.table foo like Value Command NA 'is.na(foo$Value)' NA 'foo$Value>1' I want to create a third column named App_command in which I have the result of the application of the command in the column Command. I have tried wit...
Francesco Tamberi
1

votes
2

answer
228

Views

Comparing and sorting elements in tuple

I have a vector and I have already sorted the tuple in accending order according to a. The structure is something like this. vect = { 42,324,{}; //[0] 43,231,{}; 45,97 ,{}; 73,32 ,{}; //[1] 112,87,{}; 114,249,{}; //[2] } I am trying to compare 'a' and group them if the difference between elements i...
Syd
1

votes
2

answer
51

Views

R: Adding values to certain indices of a vector

I have a vector with 10000+ entries, approximately 4000 of them are zeros. I want to add random values to those entries which are NOT zero. I know how to find out which indices are zero, but how can I make the addition?. For example consider this vector with only 10 indices v
Parinn
1

votes
1

answer
38

Views

Renaming filenames in two directories IF certain characters between them match - vector subscript out of range

My first job as an intern was to write a program to compare certain characters in the filenames of two different directories, and if they match, rename them. I wrote a custom code to match the characters. The initial few files get renamed in both directories, but it breaks after a point, giving a ve...
raynol025
1

votes
0

answer
68

Views

How to modify a HashMap with vector values? [duplicate]

This question already has an answer here: How to lookup from and insert into a HashMap efficiently? 1 answer Is there any way to return a reference to a variable created in a function? 2 answers I'm trying to build a HashMap with vectors as values and I have problems with borrowing / lifetimes. Th...
Matilda Smeds
1

votes
1

answer
231

Views

C# Painting a form into a MetaFile graphics object

I hope that question was not asked before. I could not find anything specific in this regard. I have a complicated custom drawn form that I would lake to save as a vector graphic (emf) using the MetaFile class in C#. Somehow I just can't get it to work. I always end up with a 1KB empty file and mayb...
Oliver Bernhardt
1

votes
0

answer
135

Views

Query vector tile server from geojson shape

The idea is the following : I have a GeoJSON Polygon and a 'vector tile' endpoint. I'd like to query the vector tile server to get relevant features filtered within the bounding box of the Polygon. (The final objective is to compute data and find out if some data intersects my Polygon, but for now l...
Cyril CHAPON
1

votes
2

answer
25

Views

removing elements from vector with specific string length

I have a vector that has random strings as elements. I am trying to loop through to find strings that are not a length of 2. If they are not a length of 2 then it should be removed from the vector. For some reason, my code is not removing all of the strings that are not a length of 2. I have tried i...
Jigar Patel
1

votes
1

answer
39

Views

How can I implement multiple delimiters when splitting a string into a vector?

My professor needs us to split a string with ignoring any punctuation so that 'Hello, my name is Jack!' will split without the comma and exclamation point. Specifically we must discard commas, periods, question marks, exclamation points, semicolons and colons. The code below works but the only delim...
Tristan
1

votes
0

answer
740

Views

Java 8 stream on untyped Vector [duplicate]

This question already has an answer here: Combining Raw Types and Generic Methods 5 answers Why does a Java generic raw class erase all generics to object when type parameters are unspecified? [duplicate] 1 answer Why won't this generic java code compile? 4 answers Why does this java 8 stream ope...
maestro
1

votes
0

answer
69

Views

using template function on vector of vector string , bubble sort only partially sorting

my output is below, bubble sort partially sorting, 'Battle Start Galatica' is one string before sorting, cats dogs monkey pear bears beat beets Battle Start Galatica bear bears be bee zebra cantaloupe cactus after sorting, bear bears be bears beat beets Battle Start Galatica bee zebra cantaloupe cac...
Isaiah Spearman
1

votes
0

answer
73

Views

Project a word on an axis of similarity between 2 words

I am using Word2Vec for word embeddings. I want to project a word W on an axis which represent the similarity of the word W to two given word W1 and W2 in a way that we can see to which word W is more similiar to, like this: image What is the best way to do it?
Codir
1

votes
0

answer
41

Views

Compiler Removes Vector Returned By Reference [duplicate]

This question already has an answer here: What is a dangling pointer? 5 answers Can a local variable's memory be accessed outside its scope? 19 answers Not quite sure why this is happening but I have the following code: vector& HeightMap::Vec3Vertices() { vector vecs; for (unsigned int i = 0; i <...
Ryoku
1

votes
0

answer
92

Views

Functions return number of times a scalar in a vector

I have to create a function n_entries(v, x) which, given a vector v and a scalar x and returns the number of times that x occurs in v. Here is what I have so far: n_entries = function (v,x) { if(x %in% v) { return(sum(x %in% v)) } } Example: n_entries(1:10, 1) should equal 1 and n_entries(c('a', 'a...
stevie kay
1

votes
0

answer
54

Views

Populating a vector of objects within a class

and I've hit my first wall on my coding project/assignment. I'm to implement functionality into code that's been done to some stage, and I cannot alter the given code so I have to work around the given structure. The code, in a nutshell, reads family relations from a text file and populates databa...
Grak
1

votes
1

answer
22

Views

whitecards (lowercase) skips other players in PlayerVector but the first - why?

I have tried for several days to find a solution to this but I am at a loss. I am creating a Cards Against Humanity game that makes use of a Player class. This player class has functions to add white cards, retrieve a white card, get rid of a white card, get name, set name, and others. The program...
A115
1

votes
1

answer
80

Views

Storing arbitrary function objects into a class member container without knowing their declaration signature

I have a class template, and I do not know if I need to have as one of its arguments class Func or not. I also do not know if I can arbitrarily store a std::function directly into a container without its template argument parameter list. My class looks something like: template class ThreadManager fi...
Francis Cugler
1

votes
2

answer
37

Views

Sum up existing vectors and ignoring missing ones

I´m trying to sum up some vectors within a function. Depending on my input, some of the vectors might be created or not. For example, I have vectors A, B, C and D: A
Ana Antunes
1

votes
1

answer
78

Views

Create a character vector with repetition of elements

I'm new to R and while practicing I couldn't work out how to create a vector whose outcome is : red yellow blue yellow blue green blue green magenta green magenta cyan . I noticed that rep(seq(1:3),times=4) + rep(0:3, each=3) [1] 1 2 3 2 3 4 3 4 5 4 5 6 so I thought it cold be useful to create a ve...
Jade
1

votes
3

answer
117

Views

How to search in vector of structure by a structure attribute?

I have a Vector of structure that is sorted on based of a variable. For ex: struct Client { string name; int sm_index; int client_id; int user_id; Client(string str, int x, int y, int c) : name(str), sm_index(x), client_id(y),user_id(c){} } Sorted on based of sm_index How can i find and fetch the...
Vishal Bhatia
26

votes
4

answer
2.2k

Views

Performance gap between vector<bool> and array

I was trying to solve a coding problem in C++ which counts the number of prime numbers less than a non-negative number n. So I first came up with some code: int countPrimes(int n) { vector flag(n+1,1); for(int i =2;i
Qin Heyang
1

votes
1

answer
43

Views

Find element in an array (matlab) with defined position (of time array)

I have one array that depends on another (i.e. I have the array of the tension (V) in function of the array of the time). I'd like to find the position of an element of the array of the tension at a particular moment of time (i.e. corresponding to a particular position of the time vector). How can I...
Giulia Lombardi
1

votes
1

answer
51

Views

How do convert a vector made of vectors in R to a single vector?

I'm working a baseball analysis program that gets data from the internet from multiple web-pages. To simplify my work I used for loops to go page by page and gather all of the data I need into a vector. Like so: player_html
w_smith404
1

votes
0

answer
47

Views

Stretch a svg circle in html

I'm trying to animate a circle to transform into a line. My problem is that the cricle turns into an oval once i stretch it, however i want it to be a straight line that is just rounded at the ends. how do i change that? svg { background: white; border: 1px dotted #3983ab; width: 96%; height: 1...
Somaxax
1

votes
1

answer
221

Views

Using Lower Bound With Vector of Object Pointers

I have this data structure: class Person { public: string email, name, surname }; class Bus { vector sortedbyemail; vector sortedbyname; }; now I want to add the pointers to the right position, so I dont have to sort later. As this led me to lower_bound() I finished with the following, not even com...
Čeněk Sůva
1

votes
1

answer
100

Views

Can I use member function of underlying container of priority_queue

As title, I created a priority_queue(default use vector as underlying container) p. Can I use vector's member function likep.push_back(a)or p.reserve(25) or even use for(auto i:p) {cout ' has no member named 'begin' etc. How should I do to if i want to use the function mentioned above, or they are j...
CodePurin
1

votes
1

answer
103

Views

Impossible to store cocos2d::Animation * in a std::vector of structure?

I work on a project made with cocos2d-x framework (c++). In my Player class, I have to manage the animations. Iinitially I had this code that worked without any problem: First, the animation object is a cocos2d Class cocos2d::Animation. Just remember that this object contains a cocos2d::Vector _fram...
Pierre Dommerc
1

votes
4

answer
60

Views

Error: No instance of constructor “Faktura::Faktura” matches the argument list

I have a problem with my C++ code. I have three classes: Osoba (=Person), Produkt (=Product) and Faktura (=invoice) Osoba.h class Osoba { public: Osoba(int vek, string jmeno); ~Osoba(); int vek; string jmeno; }; Osoba.cpp Osoba::Osoba(int vek, string jmeno) { this->vek = vek; this->jmeno = jmeno; }...
Mark B.
1

votes
1

answer
58

Views

SFML: How to overload Packet operator >> with a std::vector?

I'm currently programming a UDP based game and I need to inform to every new player that connects to the game about every connected player's position and other data. If I could overload the > operators to send a packet with all the player's data stored on the server. How I could solve this problem?
Taeron
1

votes
1

answer
69

Views

Android tooltip up word

in my android application tooltip is there ,created by using vector path but it is downward direction I want opposite direction ie upward which portion I need to change in my code please help me. this is my code [![< ?xml version='1.0' encoding='utf-8'?> < vector xmlns:android='http://schemas.andr...
1

votes
1

answer
33

Views

Python pair-wise multiplication using broadcasting on the first dimension

I have one-hot vector of shape 1 * n v= [0.0, 1.0, 0.0] for n = 3 and a matrix of shape n * m * r as( m and r can be any number but the first dimention is as n) m = [[[1,2,3,],[4,5,6]], [[5,6,7],[7,8,9]], [[2,4,7],[1,8,9]]] I want to multiple a * b using a broadcasting mechanism such that only the s...
Mahmood

View additional questions