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

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.

主站蜘蛛池模板: 南宫市| 樟树市| 石家庄市| 长泰县| 凤台县| 普安县| 花垣县| 新乐市| 登封市| 重庆市| 吉安市| 遵义市| 沭阳县| 南丰县| 江山市| 石泉县| 佛坪县| 青阳县| 浦县| 紫云| 明光市| 长岛县| 望城县| 巴青县| 岫岩| 出国| 宣化县| 香港| 乃东县| 日土县| 西乡县| 汉源县| 嵩明县| 贵州省| 巴中市| 东丰县| 满城县| 宣威市| 凯里市| 栖霞市| 探索|