vector Questions
8
Solved
Consider a vector:
int = c(1, 1, 0, 5, 2, 0, 0, 2)
I'd like to get the closest subsequent index (not the difference) for a specified value. The first parameter of the function should be the vector...
5
Solved
I have a vector of 0s and 1s and want to identify the indices where a string of 0s is surrounded by 1s. If the number of 0s between the 1s is lower or equal than 5, I want to change these zeros to ...
2
I want to know if two vectors have any elements in common. I don't care what the elements are, how many common elements there are, or what positions they are at within either vector. I just need a ...
Meekins asked 23/10, 2018 at 4:25
7
Solved
Looking at some code I'm maintaining in System Verilog I see some signals that are defined like this:
node [range_hi:range_lo]x;
and others that are defined like this:
node y[range_hi:range_lo]...
Imaimage asked 25/1, 2009 at 12:35
2
Solved
I have a vector [(5, 1), (9, 1), (4, 2)]
I want it to be sorted as [(4, 2), (9, 1), (5, 1)]
Which is sorted in descending order by every second element then the first element.
Would it be possible ...
4
Solved
(This is a follow-on to Sum vector with range-v3)
If I have two (or more) vectors, I can zip them together with range-v3 like this:
std::vector< int > v1{1,1,1};
std::vector< int > v2...
8
Solved
I have a vector vec of structures. Such a structure has elements int a, int b, int c. I would like to assign to some int var the element c, from the last structure in a vector. Please can you provi...
1
Solved
Background information about what inspired my question:
I learned about Designated Initializers in C (see here and here: https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html), which are awesome...
Laoag asked 27/1, 2022 at 4:8
5
Solved
I have a numeric vector like this x <- c(1, 23, 7, 10, 9, 2, 4) and I want to group the elements from left to right with the constrain that each group sum must not exceed 25. Thus, here the firs...
Brune asked 26/1, 2022 at 8:41
4
Solved
I have written following code snippet but it does not seem to be working.
int main(){
int VCount, v1, v2;
pair<float, pair<int,int> > edge;
vector< pair<float, pair<int,int...
Ceroplastic asked 1/9, 2014 at 12:41
6
Solved
I want to calculate the angle between 2 vectors V = [Vx Vy Vz] and B = [Bx By Bz].
is this formula correct?
VdotB = (Vx*Bx + Vy*By + Vz*Bz)
Angle = acosd (VdotB / norm(V)*norm(B))
and is ther...
2
Solved
I have an enum with different variants and I want to find the first variant that matches then transform it by either returning the variant value or mapping it to something else.
In Scala, I'd use...
2
Solved
I'm playing with Rust and I wonder how I can print an array and a vector.
let a_vector = vec![1, 2, 3, 4, 5];
let an_array = ["a", "b", "c", "d", "e"];
I want to print on the screen and the resu...
5
Solved
I have some data which looks like this (fake data for example's sake):
dressId color
6 yellow
9 red
10 green
10 purple
10 yellow
12 purple
12 red
where color is a factor vector. It is no...
7
Solved
I am a newbie to R. I have a list t1 in R which looks like
[[1]]
[[1]][[1]]
[1] "a" "control"
[[2]]
[[2]][[1]]
[1] "a" "disease1"
[[3]]
[[3]][[1]]
[1] "a" "disease2"
[[4]]
[[4]][[1]]
[1] "b...
4
Solved
8
Solved
Why doesn't pop_back() have a return value? I have Googled regarding this and found out that it makes it more efficient. Is this the only reason for making it so in the standard?
4
Solved
I want to replace an element into a specific position of a vector, can I just use an assignment:
// vec1 and 2 have the same length & filled in somehow
vec1;
vec2;
vec1[i] = vec2[i] // insert...
Williwaw asked 17/7, 2011 at 21:14
2
I have some integer value representing a bitmask, for example 154 = 0b10011010, and I want to construct a corresponding signal Vector<T> instance <0, -1, 0, -1, -1, 0, 0, -1> (note the ...
Encyclical asked 21/12, 2021 at 13:16
8
Solved
My question is how to initialize an eigen Matrix, but NOT this way:
matrix << 1,0,1,0,
1,0,1,0,
1,0,1,0,
I have a Matrix that looks like the above one ( commas or no commas doesnt matter...
4
I'm experimenting with using axis-angle vectors for rotations in my hobby game engine. This is a 3-component vector along the axis of rotation with a length of the rotation in radians. I like them ...
Abruzzi asked 30/11, 2010 at 17:42
4
Solved
I am trying to make a C++ program that receives user input, and extracts the individual words in the string, e.g. "Hello to Bob" would get "Hello", "to", "Bob". Eventually, I will be pushing these ...
2
Solved
How do I initialize a vector from 0 to n in Rust? Is there another way of doing that than creating an empty vector and invoking push inside a loop?
I prefer a one-liner.
2
Solved
thanks for your help. I'm trying to write an R function that will take a list containing numeric vectors and merge all the list elements which share numbers. I'm not sure I'm explaining the problem...
2
Solved
Context
This question is related to this one.
In Julia, I wanted to make a 2-dimensional array of 5 x 5 with the (i, j) element having [i,j] like this:
5×5 Matrix{Vector{Int64}}:
[1, 1] [1, 2] [1,...
Unsecured asked 13/12, 2021 at 11:12
© 2022 - 2024 — McMap. All rights reserved.