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

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.

主站蜘蛛池模板: 凤阳县| 公安县| 阿巴嘎旗| 连平县| 元阳县| 都昌县| 深圳市| 武穴市| 上思县| 中西区| 时尚| 房产| 井冈山市| 客服| 安多县| 汕尾市| 漠河县| 新晃| 涟水县| 花莲市| 邵东县| 洪泽县| 十堰市| 龙川县| 庆云县| 五寨县| 天长市| 洞口县| 曲阳县| 沙洋县| 石泉县| 清镇市| 富宁县| 清徐县| 仁布县| 隆林| 崇礼县| 南昌市| 海伦市| 太原市| 永德县|