This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Divide a scalar by a vector

Tags: None
(comma "," separated)
User avatar
Koldo
Registered Member
Posts
16
Karma
0

Divide a scalar by a vector

Fri Feb 01, 2019 2:23 pm
I wanted to assign a vector with a scalar divided by a vector.
How could be done?

Code: Select all
VectorXd w;
... // w initialization
VectorXd T = 2/w; // This is not directly possible. How to do it?

Koldo
Royi
Registered Member
Posts
34
Karma
0

Re: Divide a scalar by a vector  Topic is solved

Mon Apr 29, 2019 6:21 am
Probably you should multiply the vector by the inverse of the scalar:

Code: Select all
VectorXd w;
... // w initialization
VectorXd T = w * (1 / 2);
User avatar
Koldo
Registered Member
Posts
16
Karma
0

Re: Divide a scalar by a vector

Thu May 02, 2019 6:12 pm
Royi wrote:Probably you should multiply the vector by the inverse of the scalar:

Code: Select all
VectorXd w;
... // w initialization
VectorXd T = w * (1 / 2);
Good idea. Thank you.


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rblackwell