Win a copy of Head First Agile this week in the Agile forum!
    Bookmark Topic Watch Topic
  • New Topic

parameter x of type array  RSS feed

 
Ricardo De Jesus
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?
 
Jeff Verdegan
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.
 
Campbell Ritchie
Marshal
Posts: 55793
164
  • 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: 55793
164
  • 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: 55793
164
  • 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: 55793
164
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please continue all discussion here.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!