Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
それ NArray でできるよ
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
tmaeda
February 08, 2014
Technology
11k
18
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
それ NArray でできるよ
tmaeda
February 08, 2014
More Decks by tmaeda
See All by tmaeda
アクターモデルの話
tmaedax
7
1.8k
Jupyter(主にnotebook)のご紹介
tmaedax
1
1.4k
VoiceText Web APIでのGolang利用事例のご紹介
tmaedax
2
2.3k
AngularJSのご紹介
tmaedax
12
6.6k
静的型付き関数型言語のススメ
tmaedax
3
1.6k
Other Decks in Technology
See All in Technology
Why is RC4 still being used?
tamaiyutaro
0
110
Docker Desktop不要の時代が来る? WSL標準の「wslc」で Linuxコンテナを動かしてみた.
ueponx
0
130
フルAIで個人開発して学んだあれこれ / yuruai vol.1
isaoshimizu
0
150
AI Agentをシステムに組み込む前にゆるく向き合ってみる
hayama17
0
170
2026-06-24_人とAIの責務分離に基づく開発プロセスの提案.pdf
takahiromatsui
0
250
テスト設計の本質を改めて考えてみる~生成AIを活用する時代だからこそ、作ったテストの説明性を高めよう~
yamasaki696
1
140
ご挨拶「10周年を迎える共創ラボのこれまでとこれから」
iotcomjpadmin
0
150
組織における AI-DLC 実践
askul
0
160
「ビジネスがわかるエンジニア」とは何か?
ryooob
0
350
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
11k
UIパーツの設計を「型」から読み解く 〜TSKaigiのセッションから得た学び〜
yud0uhu
0
100
Flow 不死:AI 時代 DevOps 的不變本質
cheng_wei_chen
2
550
Featured
See All Featured
Facilitating Awesome Meetings
lara
57
7k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
370
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.7k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
120k
The Curse of the Amulet
leimatthew05
2
13k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
330
Designing for Performance
lara
611
70k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Statistics for Hackers
jakevdp
799
230k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
280
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.2k
Transcript
ͦΕ/"SSBZͰ Ͱ͖ΔΑ 札幌中央区RRuubbyy会議0011 22001144年22月88日 @@ttmmaaeeddaa
!UNBFEB
!UNBFEB w3VCZྺ͏ʹͳΓ·͢ɻ
!UNBFEB w3VCZྺ͏ʹͳΓ·͢ɻ (C)Ωϟϓςϯཌྷ
!UNBFEB w3VCZྺ͏ʹͳΓ·͢ɻ (C)Ωϟϓςϯཌྷ
!UNBFEB wͦͷੲຊΛॻ͍ͨΓ͠·ͨ͠ɻ
!UNBFEB wաڈճ΄Ͳࡳຈ3VCZձٞͰ3BJMTͷ͓Λ͞ ͖ͤͯ·ͨ͠ɻ
!UNBFEB w ג ͑ʹ͠ςοΫͰͲͬΓ3VCZͰࣄ͕Ͱ͖ ͯͤͰ͢ɻ
ࠓޚࣾͷϏδωε Ͱ͝׆༻͍͚ͨͩΔ /"SSBZ ͷ͝ఏҊͰ͢ɻ
/"SSBZʁ ॳࣖ ໊લ͙Β͍ฉ͍ͨࣄ͋Δ ͬͨ͜ͱ͋Δ Α͘͏
/"SSBZ wాதণ͞Μ࡞ͷ3VCZ༻ଟ࣍ݩྻܭࢉ ϥΠϒϥϦɻ wओʹେྔͷܭࢉΛߴʹॲཧ͢Δ͜ͱΛ తʹ࡞ΒΕͨͷɻ http://magazine.rubyist.net/?0006-RLR
ͲΕ͙Β͍͍͔ʁ ྻཁૉ ඵ ྻʹ͔Β·ͰͷཚΛ֨ೲ͠ɺͦͷ߹ܭɺฏۉɺࢄɺ࠷େɺ࠷খΛٻΊΔͷʹ͔͔ͬͨ߹ܭඵ 3VCZ /"SSBZ .BD#PPL"JS*OUFM$PSFJ()[
ͲΕ͙Β͍͍͔ʁ ྻཁૉ ඵ ྻʹ͔Β·ͰͷཚΛ֨ೲ͠ɺͦͷ߹ܭɺฏۉɺࢄɺ࠷େɺ࠷খΛٻΊΔͷʹ͔͔ͬͨ߹ܭඵ 3VCZ /"SSBZ .BD#PPL"JS*OUFM$PSFJ()[ ഒ ߴ
ͲΕ͙Β͍͍͔ʁ ྻཁૉ ඵ ྻʹ͔Β·ͰͷཚΛ֨ೲ͠ɺͦͷ߹ܭɺฏۉɺࢄɺ࠷େɺ࠷খΛٻΊΔͷʹ͔͔ͬͨ߹ܭඵ 3VCZ /"SSBZ .BD#PPL"JS*OUFM$PSFJ()[ ഒ ߴ Ͱɾ͢ɾ͕ʜ
ඵ ඵ ඵ
ສ݅Ҏ ্ͷܭࢉΛΑ ͘ඞཁͱ͢Δ ਓʙʁ ඵ ඵ ඵ
ͰɺͲΜͳ ʹখͯ͘͞ ͍͍ͷͰɺද ܭࢉΛΑ͘ඞ ཁͱ͢Δ ਓʙʁ
ͱ͍͏Θ͚Ͱɺࠓ /"SSBZͷ໘ΑΓ ɺදܭࢉػೳʹ ண͓ͨ͠Λ͠·͢ɻ
ྫ͑ɺ͜Μͳද
ྫ͑ɺ͜Μͳද ߦશମͷ߹ܭʁ
&YDFMͩͱʁ
3VCZඪ४ͷ"SSBZͩͱʁ a = [[1,2,3], [4,5,6], [7,8,9]] => [[1, 2, 3],
[4, 5, 6], [7, 8, 9]] a[1].inject(:+) => 15
/"SSBZͩͱʁ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[true, 1] => NArray.int(3): [ 4, 5, 6 ] na[true, 1].sum => 15
/"SSBZͩͱʁ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[true, 1] => NArray.int(3): [ 4, 5, 6 ] na[true, 1].sum => 15 JOUܕͷ ºͷ࣍ݩ ྻΛ༻ҙͯ͠
/"SSBZͩͱʁ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[true, 1] => NArray.int(3): [ 4, 5, 6 ] na[true, 1].sum => 15 ࢝·ΓͰɺ ͣͭ૿Ճ͢ΔͰ ຒΊΔ
/"SSBZͩͱʁ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[true, 1] => NArray.int(3): [ 4, 5, 6 ] na[true, 1].sum => 15 ศ্ٓɺԣ࣠ΛY࣠ɺ ॎ࣠ΛZ࣠ͱݺͼ·͢ Αɻ Y Z
/"SSBZͩͱʁ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[true, 1] => NArray.int(3): [ 4, 5, 6 ] na[true, 1].sum => 15 Y࣠શ෦ɺ Z࣠൪ɺ Λऔಘ ศ্ٓɺԣ࣠ΛY࣠ɺ ॎ࣠ΛZ࣠ͱݺͼ·͢ Αɻ Y Z
/"SSBZͩͱʁ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[true, 1] => NArray.int(3): [ 4, 5, 6 ] na[true, 1].sum => 15 ͦΕΛ߹ܭ
·ͱΊΔͱʁ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[true, 1].sum => 15
/"SSBZͷಛ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[true, 1].sum => 15 ͪΌΜͱºͷܗ Ͱදࣔͯ͘͠ΕΔ
/"SSBZͷಛ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[true, 1].sum => 15 ૢ࡞શͯNBQɻ ࣗͰNBQ JOKFDUͳͲΛॻ ͘ඞཁͳ͍ɻ
ൺͯΈ·͠ΐ͏ x࣠ํͷ߹ܭ Array a[1].inject(:+) NArray na[true, 1].sum
ൺͯΈ·͠ΐ͏ x࣠ํͷ߹ܭ Array a[1].inject(:+) NArray na[true, 1].sum /"SSBZͷํ͕ײత Ͱ͕͢ɺ "SSBZͰ
·ͩڐͤΔϨϕϧ
Z࣠ํͷ߹ܭ ͬͯΈ·͠ΐ͏
ྫ͑ɺ͜Μͳද "ྻશମͷ߹ܭʁ
&YDFMͩͱʁ
3VCZඪ४ͷ"SSBZͩͱʁ a = [[1,2,3], [4,5,6], [7,8,9]] => [[1, 2, 3],
[4, 5, 6], [7, 8, 9]] a.map{|row| row[0]}.inject(:+) => 12
/"SSBZͩͱʁ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[0, true] => NArray.int(3): [ 1, 4, 7 ] na[0, true].sum => 12
/"SSBZͩͱʁ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[0, true] => NArray.int(3): [ 1, 4, 7 ] na[0, true].sum => 12 Y࣠൪ɺ Z࣠શ෦ Λऔಘ Y Z
/"SSBZͩͱʁ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[0, true] => NArray.int(3): [ 1, 4, 7 ] na[0, true].sum => 12 ͦΕΛ߹ܭ
·ͱΊΔͱʁ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[0, true].sum => 12
ൺͯΈ·͠ΐ͏ x࣠ํͷ߹ܭ y࣠ํͷ߹ܭ Array a[1].inject(:+) a.map{|row| row[0]}. inject(:+) NArray na[true,
1].sum na[0, true].sum
ൺͯΈ·͠ΐ͏ x࣠ํͷ߹ܭ y࣠ํͷ߹ܭ Array a[1].inject(:+) a.map{|row| row[0]}. inject(:+) NArray na[true,
1].sum na[0, true].sum "SSBZͩͱɺྻͷ߹ܭͷͱ͖ͷίʔυͱશ͘ର শੑ͕ͳ্͍ʹɺগͯ͘͠Կ͍ͬͯΔͷ͔ Θ͔Γʹ͍͘Ͱ͢Ͷ
͜͜·Ͱͷ·ͱΊ w/"SSBZͰදΛදͱͯ͠ѻ͑·͢ɻ wૢ࡞શͯNBQJOKFDUʹ૬͢ΔͷͰɺࣗ ͰNBQJOKFDUΛॻ͘ඞཁ͕͋Γ·ͤΜɻ
ͬͱෳࡶͳྫ ͬͯΈ·͠ΐ͏
ूܭද࡞͍ͬͯͩ͘͞Ҋ݅
ूܭද࡞͍ͬͯͩ͘͞Ҋ݅ Α͋͘Γ·͢ΑͶʁ
ͷখܭΛٻΊΔʹʁ
3VCZඪ४ͷ"SSBZͰߟ͑ Δͷ͏ࢭΊ·ͯ͠ʜ
/"SSBZͰ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[true, [0,1]] => NArray.int(3,2): [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] na[true, [0,1]].sum(1) => NArray.int(3): [ 5, 7, 9 ]
/"SSBZͰ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[true, [0,1]] => NArray.int(3,2): [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] na[true, [0,1]].sum(1) => NArray.int(3): [ 5, 7, 9 ] Y࣠શ෦ɺ Z࣠൪ͱ൪ Λऔಘ Y Z
/"SSBZͰ na = NArray.int(3,3).indgen!(1,1) => NArray.int(3,3): [ [ 1, 2,
3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] na[true, [0,1]] => NArray.int(3,2): [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] na[true, [0,1]].sum(1) => NArray.int(3): [ 5, 7, 9 ] ͦΕΛZ࣠ํʹ ߹ܭ
ͪͳΈʹ na[true, [0,1]] => NArray.int(3,2): [ [ 1, 2, 3
], [ 4, 5, 6 ] ] na[true, [0,1]].sum(0) na[true, [0,1]].sum(1) na[true, [0,1]].sum => NArray.int(2): [ 6, 15 ] => NArray.int(3): [ 5, 7, 9 ] => 21
ͪͳΈʹ na[true, [0,1]] => NArray.int(3,2): [ [ 1, 2, 3
], [ 4, 5, 6 ] ] na[true, [0,1]].sum(0) na[true, [0,1]].sum(1) na[true, [0,1]].sum => NArray.int(2): [ 6, 15 ] => NArray.int(3): [ 5, 7, 9 ] => 21 TVN ͩͱɺ Y࣠ํʹ߹ܭ͞Εͯ
ͪͳΈʹ na[true, [0,1]] => NArray.int(3,2): [ [ 1, 2, 3
], [ 4, 5, 6 ] ] na[true, [0,1]].sum(0) na[true, [0,1]].sum(1) na[true, [0,1]].sum => NArray.int(2): [ 6, 15 ] => NArray.int(3): [ 5, 7, 9 ] => 21 TVN ͩͱɺ Z࣠ํʹ߹ܭ͞Εͯ
ͪͳΈʹ na[true, [0,1]] => NArray.int(3,2): [ [ 1, 2, 3
], [ 4, 5, 6 ] ] na[true, [0,1]].sum(0) na[true, [0,1]].sum(1) na[true, [0,1]].sum => NArray.int(2): [ 6, 15 ] => NArray.int(3): [ 5, 7, 9 ] => 21 TVNͩͱɺ શํʹ ߹ܭ͞Ε·͢
ͭ·Γɺ͜ͷลશ෦ɺTVN ͰٻΊΒΕΔΘ͚Ͱ͢ʂ TVN TVN TVN
͜Μͳߟ͑ํ ͋Γ·͢ɻ
͍ͭ͘ͷ࣠Ͱྨ͞Εͨ දͰ͠ΐ͏͔ʁ
͍ͭ͘ͷ࣠Ͱྨ͞Εͨ දͰ͠ΐ͏͔ʁ ੈͷ࣠
͍ͭ͘ͷ࣠Ͱྨ͞Εͨ දͰ͠ΐ͏͔ʁ ੑผͷ࣠
͍ͭ͘ͷ࣠Ͱྨ͞Εͨ දͰ͠ΐ͏͔ʁ ళͷ࣠
ͱ͍͏͜ͱɺ࣍ݩ ͷදͰ࣋ͭํ͕ࣗવ ͳͷͰʁ
͜Μͳײ͡ "ళ #ళ $ళ
உ ঁ ººͷදʢۭؒ
na = NArray.int(3, 2, 2).indgen!(1, 1) => NArray.int(3,2,2): [ [
[ 1, 2, 3 ], [ 4, 5, 6 ] ], [ [ 7, 8, 9 ], [ 10, 11, 12 ] ] ] /"SSBZͰදݱ͢Δͱʁ
na[0, 0, 0] => 1 na[0, 1, 0] => 4
na[0, 0, 1] => 7 Λऔಘͯ͠Έ·͠ΐ͏ "ళ உ "ళ ঁ "ళ உ
ͷશ෦ʁ na[true, true, 0] => NArray.int(3,2): [ [ 1, 2,
3 ], [ 4, 5, 6 ] ] na[true, true, 0].sum => 21 ళશ෦ ੑผશ෦
உੑͷશ෦ʁ na[true, 0, true] => NArray.int(3,2): [ [ 1, 2,
3 ], [ 7, 8, 9 ] ] na[true, 0, true].sum => 30 ళશ෦ ੈશ෦ உੑ
ͬͱศརʹʂ w/"SSBZԿ࣍ݩͷσʔλͰѻ͑Δ w͍͍ͪͪͱྻͷΠϯσοΫεΛ಄Ͱߟ͑ͯ ରԠ͚ͮΔͷ໘ͳͷͰɺͦ͜Λਓʹ༏͍͠ײ ͡ͷϥούʔΛඃͤͯ͋͛Δͱɺҙͷͷ࣠ ͰσʔλΛཧͰ͖Δശ͕Ͱ͖͕͋Γ·͢ɻ
cube = Cube.new([ {key: :mise, values: ["Aళ", "Bళ", "Cళ"]}, {key:
:sedai, values: ["10","20"]}, {key: :sei, values:["உ","ঁ"]} ]) # ళA, 20, ঁʹ20Λઃఆ cube.set( { mise: "Aళ", sedai: "20", sei: "ঁ" }, 20) # ళA, 20, ঁͷΛऔಘ cube.get( { mise: "Aళ", sedai: "20", sei: "ঁ" }) => 20 # 10ͷΛऔಘ cube.get( { sedai: "10"} ) => NArray.int(3,2): [ [ 1, 2, 3 ], [ 7, 8, 9 ] ]
·ͱΊ w/"SSBZҙͷͷ࣠ͷσʔλΛࣗ༝ʹѻ͑ ·͢ɻ w/"SSBZͦͷσʔλۭؒͷதͷ͖ͳॴͷ σʔλʹॊೈʹΞΫηεͰ͖·͢ɻ w&YDFM͙Β͍ΧδϡΞϧʹ/"SSBZΛ͍·͠ ΐ͏ʂ
ࢀߟ wϚχϡΞϧ IUUQOBSSBZSVCZGPSHFPSHJOEFYIUNMKB w3VCZٯҾ͖Ϩγϐ Ϩγϐ wOVNQZؔͷࢿྉ
ͥͻޚࣾͷϏδωε ͝׆༻͍ͩ͘͞ɻ