Questions tagged [vector]

12347 questions
1

votes
1

answer
408

Views

FFmpeg how to get an image for a particular 'coded_picture_number' together with motion vectors

I am looking for ways to get this output from ffmpeg: Basically, I would like to pass to the shell, a command that allows me to output a particular frame number, let's say coded_picture_number=200 with the motion vectors drawn into it. Any clue? Thanks in advance.
user102859
-2

votes
0

answer
19

Views

I want to be able to subtract or add the value of the index to the index so that the index move to the right or the left

I am writing a code in C++ and I want to add the value of the index to the index so that it shift the index either left or right. user enters 13141118 and then i assign those number an index from 0 to 7. index: 0 1 2 3 4 5 6 7 input: 1 3 1 4 1 1 1 8 and I want to add the value of index[0] which is...
jaymar
1

votes
1

answer
58

Views

Go to specific element C

I want to use a for loop to iterate through vector and when a certain condition is met, I want to go back to a certain element of vector and restart the loop from there. For example, let's say that my vector is 1,2,3,4,5,6,7,8,9; and when the first element that is bigger than 5 is met, I want to res...
Xyz
1

votes
2

answer
33

Views

Replace search icon in react-native-paper searchbar with icons from MaterialCommunityIcons

I want to change the search icon in the searchbar of react-native-paper with the barcode-scan icon. The native-paper uses react-native-vector-icons for icons and barcode-scan available in MaterialCommunityIcons Here is the code that I tried which gives a blank instead of an icon import MaterialCommu...
Aditya Sharma
1

votes
1

answer
58

Views

Why does my code not add every object into the vector?

I am reading from a file and with the information that I receive I want to parse the data and store them into their respectful objects which will then be pushed back into a vector. However, when the code stores the information into the object and is then pushed back into the vector, the vector does...
Darryl Brooks
1

votes
1

answer
73

Views

Why I can't input into my std::vector in C++

I'm a newbie in C++. I've just learnt about vector in STL. However, when I tried to input an integer into my vector: vector v; cin>>v[i] The program returned segmentation fault. Please help me out.
Shrike Danny
1

votes
3

answer
47

Views

Runtime error when using push_back() on smart pointer to vector

I am trying to fill a vector, by dereferencing a smart-pointer. During runtime the program crashes after one iteration of the first 'for' loop used for entering the variable input. using namespace std; class Measurement { protected: int sample_size; string label; shared_ptr data; public: // paramet...
user2013904
1

votes
1

answer
64

Views

Linux much faster than Windows when reading data from .txt file and placing into vector. How would I speed up Windows to do the same?

I have .txt files for data (100MB - 700MB). When reading these files and placing them into vectors, Linux does this 20-30x faster. Is this a system issue, or is there something I can do to speed up Windows? I've ran the same code hundreds of times on each system. Both systems have a 64bit compiler...
Lumbeezl
0

votes
1

answer
51

Views

How to find the index of an element in a sorted vector given a pointer to that element

I have a vector std::vector vec. I'm trying to sort the vector and then find the index of an element given a pointer to it sort(vec.begin(), vec.end(), ...); auto index = myPointer - &vec[0]; I noticed that the value of index doesn't change when the vector is sorted and therefore is incorrect. Is t...
vuoriov4
1

votes
3

answer
2.7k

Views

c++ find position of maximum value in 2D std::vector

Suppose we have 2D vector of int like: 1 4 3 0 1 5 6 3 2 0 0 1 6 5 9* 3 3 5 4 2 Now How can I find the position of maximum value in the 2D vector: [2][3]==9 in the example above.The answer would be 2,3 I know I can use std::max_element() but it gives iterator. Another po...
batista cori
1

votes
2

answer
305

Views

How to make sure the accessed index in a vector exists?

I have a vector of text labels std::vector texts_. I can create texts and push them into the vector like this: texts_.push_back(utils::createText(x, y, 'SomeString1')); texts_.push_back(utils::createText(x, y, 'SomeString2')); // etc. and then easily draw them like this: for (std::size_t i = 0; i <...
A. D.
0

votes
1

answer
21

Views

How to generate a vector 10000 times and each time store a certain position?

So, I have a certain normal distribuition and its mean is replicated 10000 times in a vector. I need to find the 9th element in the vector that is out of the limits of control and store its position, which I've been able to do. Now, how to repeat this action 10000 times and store 10000 positions as...
Carlos Junior
2

votes
2

answer
27

Views

i need to find the first negative number in each column of a matrix

Hello i need to find the position of first negative number for each row vector in a matrix i've tried with match and apply but it ony shows the first z
Matteo Esposito
1

votes
1

answer
86

Views

c++ add data to a std::vector containing a std::tuple

Below is code that adds elements to a vector containing a std::pair std::vector args_; template inline OperationEntry& setArg(const std::string& name) { args_.push_back({name, typeid(T)}); return *this; } How do I add elements to a vector containing a std::tuple? std::vector args_; template inline...
cherry aldi
1

votes
1

answer
77

Views

R circular “linked” list: adding +1 to last index brings you to first index

I'm trying to implement movement through four points, while recording which points I visit. Think of it as a square. I can move from corner to corner or diagonally. If you 'unwrap' the square you get a straight line with four points, which can be thought of as 1-2-3-4- where after 4 it goes back to...
George
1

votes
1

answer
38

Views

Select random and unique elements from a vector

Say I have a simple vector with repeated elements: a
GabrielMontenegro
1

votes
1

answer
129

Views

Julia : How to convert vector of type string to type numeric (Float64)

In Julia 1.1 I want to convert a vector of type string to type numeric (Float64) here is the vector: string = ['2.2', '3,3', '4.4']; I tried the following line without success: x = convert(Float64, string) x = convert(DataVector{Float64}, string) x = map(x->parse(Float64,x),string) x = parse(Float...
ecjb
1

votes
2

answer
45

Views

Add sequence between each pair of values of a numeric vector

I have a numeric vector, which I would like to extent with a sequence of three additional numbers between each two values of this vector. Consider the following example: # Example vector set.seed(123) x
JSP
1

votes
1

answer
61

Views

Vector push_back calls object destructor

Similar questions have been asked here many times, following the answers didn't solve my problem though. Let's say I have: 1)Two classes (ACLass and BClass) 2)AClass has a contructor and a destructor 3)BClass has a std::vector member that stores objects of AClass 4)Number of elements in that vector...
Chriss555888
1

votes
3

answer
149

Views

Unity: Convert Vector2 to Vector2Int

I have a Vector2 and I want to convert it into a Vector2Int. I know I could convert the Vector2 with something like this: Vector2 v2 = new Vector2(10, 10); Vector2Int v2i; v2i = new Vector2Int((int) v2.x, (int) v2.y); But is there a shorter or more effective way? For example something like this: v2i...
Timisorean
1

votes
1

answer
54

Views

C++ Why emplacing object in vector segfaults?

I want to create a vector of 'Act' objects that contain pointers to either 'Eat' or 'Drink' dynamically allocated objects. The new objects are being emplaced like so: action_vector.emplace_back(Act::BehaviorType::eat); However, it is seg-faulting and I can't figure out why. I thought that emplace_ba...
user2520385
1

votes
2

answer
77

Views

Why c++ vector inner elements/array are copied when passed by value

Why does the inner elements of the vector are copied when the vector is passed by value? #include using namespace std; // this func won't modify v[2]. // Meaning v[2] (and the whole inner array) was copied // when v is passed to the func? void modify(vector v) { v[2] = 100; } // this func modify v...
phanhuy152
1

votes
4

answer
61

Views

How can I print a vector in a recursive function?

I have a problem here: I am to write a function that prints the elements of a vector recursively so no loop is allowed. I tried this code but it crashes at runtime: void print(const std::vector ivec, std::vector::const_iterator it) { if (it == ivec.end()) return; std::cout
Syfu_H
1

votes
2

answer
84

Views

How to get a minimum value from a vector with (value > 0)

I'm trying to reduce by some value all the elements of a vector that are not or less than 0. I haven't really tried anything because I just can't get around with this, but I Need, for example, from a vector{1, 2, 3, 0, -1} the value vector[0] I don't want to sort or remove any value, I need the vect...
PlayLikeMe10YT
1

votes
1

answer
44

Views

Creating a bar chart in R from data in a file

First I have created two vectors and put them together Vectors: VektorLHI and VektorRHI sumLHIundRHI
Silvia
1

votes
2

answer
127

Views

Choose some numbers coding in Gray Code

I have to write a programm that shows some numbers coding in Gray Code. I already found an algorithm written in C++ in this page ( https://www.geeksforgeeks.org/given-a-number-n-generate-bit-patterns-from-0-to-2n-1-so-that-successive-patterns-differ-by-one-bit/ ). But I want to create a new method t...
Red One
0

votes
1

answer
14

Views

Vectors pointers with vector slices for Tree generation from preorder and inorder vectors

I'm getting the following error: solution.cpp: In member function buildTree Line 26: Char 62: error: no matching function for call to 'Solution::buildTree(__gnu_cxx::__alloc_traits, int>::value_type*, std::vector*)' root->left = buildTree(&preorder[index],&inorderslice); ^ In this code: class Solut...
JoaoAntunes
1

votes
3

answer
176

Views

Passing STL vector wrapped in shared_ptr [duplicate]

This question already has an answer here: Is it bad practice to allocate memory in a DLL and give a pointer to it to a client app? 10 answers I'm wondering about a situation where I'm trying to return a vector from DLL to .exe app. Compilers and settings for DLL and .exe app are the same. I know th...
drewpol
1

votes
0

answer
862

Views

how to give an elevation to a ConstraintLayout which has a vector background

I have a ConstraintLayout with a vector background. I want to set an elevation to the layout. If i remove the vector background then the elevation work but not otherwise. I am using the vector background to get a curved layout. So both are necessary. Please help me in this layout_background activit...
Satyaraj Moily
1

votes
0

answer
97

Views

What's the meaning of ::std::vector [duplicate]

This question already has an answer here: What is the meaning of prepended double colon “::”? 9 answers C++ : what is :: for? 5 answers I just saw in some DLib code, in a .cpp file a thing like that: #include namespace { using namespace std; void foo() { ::std::vector my_vector; } } Is there...
baptiste
1

votes
2

answer
87

Views

Assigning a std::set to a 2D std::vector of ints

I'm trying to make a integer Matrix with no numbers repeated and its elements sorted so I was making it with a std::vector but then, searching on internet and Stackoverflow, I've found something called std:set which I see is a container and it has just the 2 properties I'm looking for: no repeated e...
Megasa3
1

votes
1

answer
1.2k

Views

Godot 3d get Forward Vector

I was wondering if there was a way to get the forward vector of a spatial node in godot 3d. In unity this would simply be transform.forward. Godot gives me a rotational vector but im not sure how to convert this to a directional vector. What is godot's version of transform.forward?
SanzioSan
1

votes
1

answer
51

Views

Initialization vector size

(Image of code I couldn’t type it due to limited site access) I have an encrypted file that i encrypted using XILINX SDK. The key file used contains a 256 bit key and a 96 bit iv. I am attempting to decrypt the file using AesCrytopServiceProvider from .net framework,however the CreateDecryptor(key...
K.T.
1

votes
2

answer
659

Views

How to read data in a file and create a vector of struct?

I tried to read a file called 'qbdata.txt' and save the data in a vector called quarterbacks. So, I created this struct 'Record' to save different types of variables in the file and 'quarterbacks' is supposed to be a vector of struct. Here is my code. However, it didn't work out. When I test the siz...
Phyllis Qu
1

votes
0

answer
50

Views

Lucene.Net FastVectorHighlighter with fine-grained Chinese segmentation tool doesn't work

enter image description here the error is: System.ArgumentOutOfRangeException: Index and length must refer to a location within the string. Parameter name: length at System.String.Substring(Int32 startIndex, Int32 length) at Lucene.Net.Search.VectorHighlight.BaseFragmentsBuilder.MakeFragment(StringB...
xiaokang
1

votes
0

answer
100

Views

Inserting a INT value into a vector location?

First of all, I am new to C++. I am trying to figure out how to insert an Int value into a certain position in a vector. I read online that you can use the insert function to push a value in a vector but i keep getting an overload operator error from my compiler. Do I need to make a pointer? Here is...
Kyle Coffey
1

votes
0

answer
37

Views

Imagick doesn't resize vector GIFs correctly PHP

I'm using imagick for image uploads and resizing. when I try to resize GIF image with vector graphics it won't resize as original. but normal animated giphys are woring. please advice https://giphy.com/explore/vector-design these giphs are not resizing with correct animation. below is my code. $ima...
1

votes
0

answer
44

Views

Iterate vector of pairs

I have vector1 [1,2,5,4,7]. I have another vector2 [(1,1),(2,5),(3,6),(4,7)]. I want to check if the element in Vector1 is the first or second element in the pair vector2. this is the code snippet. Any better approach other than this which takes less time ? std::vector vector1; std::vector vector2;...
spnsp
1

votes
1

answer
43

Views

vector of boost::function not working with _placeholder

I need your help. I tried a lot to find a solution for the problem but failed so far. Idea: Create a vector of 'command tuples' like the following: typedef boost::tuple command_tuple; std::vector commands { boost::make_tuple('command1', boost::bind(&myclass::command1, this)) }; If the string 'comman...
drtyhlpr
1

votes
1

answer
216

Views

R Accessing vector inside list inside Array

I have a very long Array (1955x2417x1) in R where each position stores a list of two vector (named 'max' and 'min') of length 5. I would like to find a simple way to create a multidimensional array (dim 1955x2417x5) where each position holds a single value from vector 'max' I have looked at answers...
ciskoh

View additional questions