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
TypeScript入門 2026
recruitengineers
PRO
1
260
Goでデータパイプラインを作ろう
sansantech
PRO
0
240
AWS ネットワーク構築でハマった(ハマりかけた) 5選とそこから得た教訓
nagisa53
4
180
制約理論(ToC)入門 2026版
recruitengineers
PRO
2
330
Redmine 7.0 新機能・機能強化解説(OSC2026京都ダイジェスト版)
vividtone
1
190
変化の早いClaude Codeを 書籍に落とし込む
oikon48
6
1.2k
[ChatGPT Work LT]事務作業が苦手な人のための バックオフィスの「半」自動化
chimaki_iot
0
190
もう一度考える SRE チームの作り方・育て方 / Rethinking SRE #1: Building and Growing SRE Teams
rrreeeyyy
5
980
ボトムアップ文化が強い組織で セキュリティをどう根付かせていくかの現在進行形の話 / Making Security Stick in a Bottom-Up Organization
yamaguchitk333
0
120
Contract One Engineering Unit 紹介資料
sansan33
PRO
0
19k
サイバー捜査員研修(後半)
nomizone
1
590
取引先から届く 「セキュリティチェックシート」の読み解き方
kamadamakoto
0
110
Featured
See All Featured
Speed Design
sergeychernyshev
33
2k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
67
56k
Making Projects Easy
brettharned
120
6.7k
The Curious Case for Waylosing
cassininazir
1
450
Building Applications with DynamoDB
mza
96
7.2k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
660
Art, The Web, and Tiny UX
lynnandtonic
304
22k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
230
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.5k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
72
41k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
420
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ؔͷࢿྉ
ͥͻޚࣾͷϏδωε ͝׆༻͍ͩ͘͞ɻ