vector Questions

1

I asked very specific question here but I realized where the problem is and it's slightly more general. Seeing ALL exprtk examples and code pieces, everyone uses exprtk's basic metod add_variable ...
Huguenot asked 26/11, 2018 at 10:13

4

Solved

I am a new python user and I was wondering how I could make a 0 to n vector. I would like the user to be able to input an integer for n, and receive an output of [0,1,2,3,4,5...,n]. This is what I...
Crownwork asked 23/7, 2012 at 3:42

2

Solved

I'm storing a class (let's call it A) in an std::vector using C++ smart pointers (so the vector sigature is std::vector<std::shared_ptr<A>>). #include <iostream> #include <me...
Stand asked 12/12, 2017 at 12:2

1

Solved

Given the following code, why is the capacity of each of the vectors 0 instead of chunk_size? #[test] fn test() { let chunk_size = 1024; let data: Vec<Vec<u8>> = vec![Vec::with_capaci...
Sigismond asked 19/9, 2023 at 18:11

11

Solved

I have two vectors u and v. Is there a way of finding a quaternion representing the rotation from u to v?
Uniparous asked 23/7, 2009 at 13:45

9

I want to edit the fill Color of a vector-file in Android programmatically. In the xml-file I can set my color with the attribute android:fillColor but I want to change the color in runtime. Any...
Fountainhead asked 14/10, 2015 at 13:37

3

I'm looking to allocate a vector of small-sized structs. This takes 30 milliseconds and increases linearly: let v = vec![[0, 0, 0, 0]; 1024 * 1024]; This takes tens of microseconds: let v = ve...
Breadstuff asked 13/12, 2019 at 0:46

4

I want to randomly assign a vector of values, some of which are duplicates, to a smaller number of groups such that at least two and no more than four values are assigned to each group, and the sam...
Amory asked 23/8, 2023 at 1:37

2

Solved

This code won't compile: fn main() { let m1 = vec![1, 2, 3]; let m2 = vec![&m1, &m1, &m1]; let m3 = vec![vec![1, 2, 3], vec![4, 5, 6], vec![7, 8, 9]]; for i in &m2 { for j in...
Mountain asked 25/2, 2016 at 14:30

4

Solved

I want to store a large n-dimensional vector (e.g. an embedding vector) in SQL Server as a piece of metadata associated with another row. In this example, it will be a 384-dimensional vector, for e...
Thill asked 3/5, 2023 at 18:44

1

Solved

Can you guess the output of this trivial program? #include <vector> #include <string> #include <exception> #include <iostream> int main() { try { struct X { explicit X(...
Happy asked 30/8, 2023 at 21:46

2

Solved

Suppose I have a vector v, how do I get its reverse, i.e. last element first? The first thing that comes to me is v[length(v):1], but it returns NA when v is numeric(0), while user normally expect...
Goldfish asked 21/9, 2013 at 13:58

1

In the following program, default constructor of struct A does not initialize its field v. Then in a constant expression, std::vector<A> is emplaced with A() object: #include <vector> ...
Roderic asked 10/8, 2023 at 21:7

5

Solved

I have the following data: x <- c(F, T, T, T, F, T, T, T, T, T) names(x) <- letters[1:10] y <- c(T, F, T, T, T, F, T, T, T, T) names(y) <- letters[1:10] z <- c(T, T, F, T, T, T, T, T...
Fostoria asked 9/8, 2023 at 14:24

7

cbind(1:2, 1:10) [,1] [,2] [1,] 1 1 [2,] 2 2 [3,] 1 3 [4,] 2 4 [5,] 1 5 [6,] 2 6 [7,] 1 7 [8,] 2 8 [9,] 1 9 [10,] 2 10 I want an output like below [,1] [,2] [1,] 1 1 [2...
Pentosan asked 13/9, 2010 at 10:5

33

Solved

How do I print out the contents of a std::vector to the screen? A solution that implements the following operator<< would be nice as well: template<container C, class T, String delim = &q...
Anchovy asked 25/5, 2012 at 7:13

33

Solved

How do I print out the contents of a std::vector to the screen? A solution that implements the following operator<< would be nice as well: template<container C, class T, String delim = &q...
Acetal asked 25/5, 2012 at 7:13

8

Solved

I know that there are similar questions to this one, but I didn’t manage to find the way on my code by their aid. I want merely to delete/remove an element of a vector by checking an attribute of t...
Whatsoever asked 25/12, 2011 at 9:12

9

Solved

I am a bit confused about this both of these look same to me. Although it may happen that capacity and size may differ on different compilers. how it may differ. Its also said that if we are out of...
Cheyney asked 9/6, 2011 at 17:35

3

Solved

I am wondering if there is a way to get cosine distance of two vectors in postgres. For storing vectors I am using CUBE data type. Below is my table definition: test=# \d vectors Table "publi...

3

Solved

I am a beginner in c++ and every time I run vector<int> nums = {2, 5, 3, 7, 1}; it gives me the Error: non-arregrate type vector cannot be initialized with initializer list. Can you tell me ...
Ium asked 18/8, 2016 at 16:0

4

According to the C++ standard, is std::vector<T>::pop_back() ever allowed to reduce the capacity of the vector? I am asking because I would like to have a guarantee, that the following code ...
Durwood asked 20/5, 2014 at 16:0

2

Solved

In C++ one can create an array of predefined size, such as 20, with int myarray[20]. However, the online documentation on vectors doesn't show an alike way of initialising vectors: Instead, a vecto...
Beatty asked 11/5, 2012 at 22:13

2

Suppose I am writing a function that takes a bunch of strings and filters out the "bad" ones. The function then returns some strings, but there is a chance that all the strings are filter...
Nedranedrah asked 18/7, 2023 at 1:12

6

Solved

I have some numbers stored in a std::vector<int>. I want to find which number appears most in the vector. e.g. in the vector 1 3 4 3 4 2 1 3 2 3 the element that occurs the most is 3. Is the...
Varden asked 21/3, 2010 at 22:8

© 2022 - 2024 — McMap. All rights reserved.