- Julia 1.0 Programming Complete Reference Guide
- Ivo Balbaert Adrian Salceanu
- 73字
- 2021-06-24 14:21:45
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.
推薦閱讀
- 在最好的年紀(jì)學(xué)Python:小學(xué)生趣味編程
- 大學(xué)計(jì)算機(jī)基礎(chǔ)實(shí)驗(yàn)教程
- JavaScript:Functional Programming for JavaScript Developers
- Mastering Concurrency in Go
- Java程序員面試算法寶典
- 小程序開(kāi)發(fā)原理與實(shí)戰(zhàn)
- Getting Started with NativeScript
- Unreal Engine 4 Shaders and Effects Cookbook
- Learning DHTMLX Suite UI
- 前端HTML+CSS修煉之道(視頻同步+直播)
- SQL經(jīng)典實(shí)例(第2版)
- 51單片機(jī)C語(yǔ)言開(kāi)發(fā)教程
- PHP+Ajax+jQuery網(wǎng)站開(kāi)發(fā)項(xiàng)目式教程
- Getting Started with Python and Raspberry Pi
- Managing Microsoft Hybrid Clouds