help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Vector division by a matrix different results when executed in Octav


From: Denis Lessard
Subject: Re: Vector division by a matrix different results when executed in Octave or Python
Date: Fri, 25 Oct 2019 21:02:55 +0000

Hi Mike

I would like to thank you so much…. you help me a lot…..

Thanks again
Denis


> On Oct 25, 2019, at 13:54, Mike Miller <address@hidden> wrote:
> 
> On Fri, Oct 25, 2019 at 12:44:53 +0000, Denis Lessard wrote:
>> import numpy as np
>> a=np.array([10,10,10])
>> b=np.array([[1,1,1],[2,2,2],[3,3,3]])
>> print(a)
>> print(b)
>> c=np.divide(a,b)
>> print("np.divide(a,b) = ")
>> print (c)
>> 
>> the results:
>> 
>> a=[10 10 10]
>> 
>> 
>> b=[[1 1 1]
>>    [2 2 2]
>>    [3 3 3]]
>> 
>> 
>> np.divide(a,b) =
>> [[10.         10.         10.        ]
>> [ 5.          5.          5.        ]
>> [ 3.33333333  3.33333333  3.33333333]]
> 
> This is the same result as Octave's ./ operator, elementwise division.
> 
>> For octave I wrote the same small program (no numpy )
>> and when I use c=a/b the results are:
>> 0.71429 , 1.42847 , 2.14286
> 
> For the equivalent linear algebra in Python, use
> 
>    (np.linalg.pinv(b).T * np.matrix(a).T).T
> 
> -- 
> mike


reply via email to

[Prev in Thread] Current Thread [Next in Thread]