vector Questions

26

Solved

I have a vector<int> container that has integers (e.g. {1,2,3,4}) and I would like to convert to a string of the form "1,2,3,4" What is the cleanest way to do that in C++? In Python this ...
Napalm asked 16/9, 2009 at 3:14

3

Solved

Let's say I have two 4-dimensional vectors (i.e. a and b) as follows: a = {a1, a2, a3, a4} b= {b1, b2, b3, b4} How do I compute the Euclidean distance between these vectors?
Ahwaz asked 29/4, 2014 at 1:30

3

Solved

Say I have a camera placed at: { x: 10, y: 30, z: 20 } It's rotation is: { x: 0.1, y: 0.2, z: 0.3 } I want to move the camera 1 unit from it's current position in the direction it's fac...
Jidda asked 27/6, 2016 at 11:20

2

Solved

Say I have a set of vectors of different lengths. I want to grab always the first 9 elements from them. However, if the vector length is <9, I want to grab all the elements, and complete up to 9...
Kramatorsk asked 5/7, 2023 at 2:17

11

Solved

I have the following vectors with 0s and 1s: test1 <- c(rep(0,20),rep(1,5),rep(0,10),rep(1,15)) test1 [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 ...
Liddie asked 29/6, 2023 at 14:46

4

Solved

I am running 64 bit R 3.1 in a 64bit Ubuntu environment with 400GB of RAM, and I am encountering a strange limitation when dealing with large matrices. I have a numeric matrix called A, that is 4...
Putandtake asked 20/6, 2014 at 21:10

4

Solved

I can't get the type of an element. This solution returns a reference to element type. int arr[] = { 0, 1, 2, 3, 4, 5 }; using arrElemType = decltype(*arr); vector<arrElemType> vec(std::cbeg...
Cayes asked 14/3, 2014 at 16:20

5

Solved

vector<vector<int>> res; res.emplace_back({1,2}); // change to res.push_back({1,2}); would work This gives me the error: main.cpp:61:25: error: no matching function for call to ‘std::v...
Clearly asked 5/12, 2013 at 4:46

11

Solved

I tried norm, but I think it gives the wrong result. (the norm of c(1, 2, 3) is sqrt(1*1+2*2+3*3), but it returns 6.. x1 <- 1:3 norm(x1) # Error in norm(x1) : 'A' must be a numeric matrix norm(...
Raguelragweed asked 7/6, 2012 at 14:34

2

I have vectors stored in BigQuery (see How can I compute TF/IDF with SQL (BigQuery)), and I want to find the most similar between them. How can I compute the cosine similarity with BigQuery standar...
Talya asked 4/12, 2017 at 5:34

9

Solved

With the new android support update, vector drawables get backward compatibility. I have a vector image with various paths. I want the color of the paths to change on click of a button or programma...
Joellyn asked 25/2, 2016 at 10:48

7

Solved

I have a (fairly long) list of vectors. The vectors consist of Russian words that I got by using the strsplit() function on sentences. The following is what head() returns: [[1]] [1] "модно" "со...
Theosophy asked 4/3, 2013 at 12:11

6

Solved

What is a recommended way to overload the output stream operator? The following can not be done. It is expected that compilation will fail if the operator << is not defined for a type T. tem...
Rianon asked 2/11, 2010 at 12:28

3

Solved

I have a vector say a = c(1,2,3,4,5,6) I would like to organize them into the elements into an upper triangle matrix (without considering diagonal elements, they are all zero) by row. My goal i...
Volumed asked 11/6, 2015 at 17:15

3

Im trying to apply a force to an object. To get it to move in the angle that my mouseposition is generating relative to the object. I have the angle targetAngle = Matter.Vector.angle(myBody.pos,...
Mutualism asked 6/3, 2016 at 12:49

2

Solved

Does std::vec::shrink_to_fit allocate a new, smaller vec.len() buffer of data, copy to it, and destruct the old buffer, or does it somehow indicate to the memory allocator that the uninitialised pa...
Hagler asked 22/5, 2023 at 17:0

7

Solved

I have a matrix with 5 columns and 4 rows. I also have a vector with 3 columns. I want to subtract the values in the vector from columns 3,4 and 5 respectively at each row of the matrix. b <- m...
Gallery asked 1/7, 2014 at 23:31

4

Solved

I'm trying to understand how up vectors and lookAt() work together in three.js. I'm setting the up vector of this axisHelper, so that the Y axis always points at the target geo, which marks the pos...
Chrissa asked 10/12, 2013 at 22:12

2

Solved

I was just messing around and learning about vectors as well as structs, and at one point, I tried outputting the size of a vector in bytes. Here's the code: #include <iostream> #include &lt...
Ensiform asked 1/12, 2015 at 16:10

2

Solved

I got this error ,,"vector" was not declared in this scope'' for the following code when I separate in *h and *cpp a file This is the main.cpp: #include <iostream> #include <math.h> #i...
Bushey asked 15/3, 2017 at 11:26

6

Solved

I have found that the easiest way to build my program argument list is as a vector of strings. However, execv expects an array of chars for the second argument. What's the easiest way to get it to ...
Buddhi asked 26/4, 2011 at 23:55

2

Solved

I want to swap elements of slice data using library function, but it doesn't work because of multiple borrowing: use std::mem; fn example() { let mut data = [1, 2, 3]; let i = 0; let j = 1; ...
Paralysis asked 3/2, 2015 at 8:50

5

I have a vector of numbers x <- c(2,5,1,6) and I am trying to generate a sequence of values -- starting from 1 -- between and including the values in x so that I am left with the following s...
Arbour asked 24/4, 2017 at 14:46

22

Solved

In our C++ course they suggest not to use C++ arrays on new projects anymore. As far as I know Stroustrup himself suggests not to use arrays. But are there significant performance differences?
Operable asked 19/12, 2008 at 17:30

7

Solved

I want to clear a element from a vector using the erase method. But the problem here is that the element is not guaranteed to occur only once in the vector. It may be present multiple times and I n...
Togo asked 7/12, 2008 at 10:10

© 2022 - 2024 — McMap. All rights reserved.