Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

I am confused using tanh(M)

$
0
0

@floriano wrote:

Hello,
I am pritty new to Julia and try to find my first steps. I am a bit confused now.
In Python I had this (simplyfied) piece of code:

import numpy as np
a = [[1,2], [3,4]]
M = np.array(a)
np.tanh(M)

It brings me the expected result:

array([[0.76159416, 0.96402758],
           [0.99505475, 0.9993293 ]])

Now I try my luck with Julia:

M = [1 2
3 4]
tanh(M)

Output:

2×2 Array{Float64,2}:
 -0.0320733  0.472079
  0.708118   0.676045

My question, what is calculated here?

However if I do:

tanh.(M)

I get the expected result again. I think I understand concept of “.” as the elementwise operator. But I thought tanh() and similar are always elementwise. If I am wrong, what is tanh(M) without “.” calculating?
Thanks
Floriano

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles