This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
    Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

parameter x of type array  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hello,

Anybody can help me please? I am trying to understand the line 5, What is the meaning of having only x instead of numbers to define the vector v2?. Below is the code:


When I run the programm I get:

v1 = ( 4.00000e+00, 5.00000e+00, 6.00000e+00)^T
v2 = ( 9.00000e+00, 8.00000e+00, 7.00000e+00, 4.00000e+00)^T
v3 = ( 1.00000e+00, 1.00000e+00, 1.00000e+00, 1.00000e+00, 1.00000e+00)^T

Was it the vector v2 generated randomly?
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi, and welcome to the Ranch!

In the future, when posting code, please UseCodeTags(←click). This will make your code more readable, and will automatically add line numbers.

As for your question, there's nothing random about it. You're passing a reference to an array of doubles to the constructor--the exact doubles that you're seeing printed out for v2. Presumably that Vector constructor iterates through the array, adding each element to itself. This is exactly the behavior I'd expect.
 
Ricardo De Jesus
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thank you for the explanation.
Yes, I just saw the numbers of the vector to be printed in the output.
 
Marshal
Posts: 60111
188
  • Mark post as helpful
  • send pies
  • Report post to moderator
I have added code tags, since you are new, and also had to remove the line numbers. You will see the code tags add their own line numbers.
 
Ricardo De Jesus
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hello Campbell,

Thank you for editing the code. I will take that into account next time I have a question to post.

Best regards.

Ricardo.
 
Campbell Ritchie
Marshal
Posts: 60111
188
  • Mark post as helpful
  • send pies
  • Report post to moderator
Why are you using Vector? Have you got an old book? Vector has been legacy code for about 12 years.
Why are you not parametrising the Vector? I think you must tell us where the question is from before we can understand it fully. That is because some books introduce confusing elements into questions. You would do well to read the documentation for Vector, which may help you understand what is happening.
 
Campbell Ritchie
Marshal
Posts: 60111
188
  • Mark post as helpful
  • send pies
  • Report post to moderator
I cannot find a print() method in the Vector class I quoted earlier. Where does this Vector class come from? You would need to inspect it before you can understand that code.
 
Campbell Ritchie
Marshal
Posts: 60111
188
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please continue all discussion here.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!