#includeint main() { yarp::sig::Vector vec(3); // Creates a 3-dimensional vector vec[0] = 1.0; // Sets the first element to 1.0 vec[1] = 2.0; // Sets the second element to 2.0 vec[2] = 3.0; // Sets the third element to 3.0 return 0; }
#includeIn this example, we concatenated two vectors by resizing the first vector and setting a subvector of the second vector. The yarp.sig Vector is part of the YARP library package.int main() { yarp::sig::Vector vec1(2, 1.0); // Creates a vector of size 2 with all elements set to 1.0 yarp::sig::Vector vec2(3, 2.0); // Creates a vector of size 3 with all elements set to 2.0 vec1.resize(5); // Resizes vec1 to size 5 vec1.setSubvector(2, vec2); // Sets elements 2, 3, and 4 of vec1 to the values in vec2 return 0; }