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

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.

主站蜘蛛池模板: 璧山县| 石城县| 杭锦旗| 瑞安市| 桃江县| 景东| 绥德县| 乌什县| 郴州市| 化州市| 峨边| 繁峙县| 福建省| 筠连县| 九寨沟县| 安龙县| 绥德县| 健康| 正定县| 丰宁| 比如县| 垫江县| 乳山市| 十堰市| 本溪| 宁乡县| 集安市| 兰州市| 莎车县| 湖州市| 平和县| 岐山县| 伊金霍洛旗| 突泉县| 永宁县| 聂荣县| 高要市| 沐川县| 嵩明县| 平凉市| 华阴市|