官术网_书友最值得收藏!

Broadcasting

A function f can be broadcast over all elements of an array (or matrix) by using the dot notation f.(matrix); for example:

arr = [1.0, 2.0, 3.0] 
sin.(arr) #> 
3-element Array{Float64,1}:
# 0.8414709848078965 # 0.9092974268256817 # 0.1411200080598672

Here is another example:

f(x,y) = x + 7y 
f.(pi, arr)  
#> 3-element Array{Float64,1}: 
# 10.141592653589793 
# 17.141592653589793 
# 24.141592653589793 

Broadcasting is very useful in Julia to write compact expressions with arrays and matrices.

主站蜘蛛池模板: 越西县| 那曲县| 南开区| 兴安盟| 当阳市| 雷山县| 阜新| 建湖县| 台前县| 隆子县| 元朗区| 滦南县| 葵青区| 乐亭县| 改则县| 西贡区| 施秉县| 浦县| 唐河县| 安义县| 无为县| 铁岭县| 崇信县| 舞阳县| 沁水县| 花莲县| 丹棱县| 靖远县| 清镇市| 双鸭山市| 奉化市| 达拉特旗| 泸州市| 乌海市| 砚山县| 光泽县| 陇西县| 涟水县| 麟游县| 政和县| 广元市|