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

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.

主站蜘蛛池模板: 富平县| 周至县| 荥阳市| 滁州市| 禹州市| 广德县| 称多县| 鄯善县| 弋阳县| 嵩明县| 合阳县| 襄垣县| 临猗县| 社会| 盘锦市| 天水市| 永顺县| 嘉鱼县| 河源市| 昭平县| 大埔县| 克东县| 阳泉市| 高陵县| 古交市| 六盘水市| 郧西县| 阿鲁科尔沁旗| 翁牛特旗| 衡山县| 鲜城| 西昌市| 陵水| 增城市| 介休市| 湘阴县| 赫章县| 永善县| 宾阳县| 措勤县| 黑水县|