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
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
LLMやAIエージェントをソフトウェアに組み込むプラクティス
shibuiwilliam
1
300
SRE Lounge Hiroshimaへの招待
grimoh
0
600
インフラ寄りSREでも 開発に踏み出せる〜境界を越えてユーザー体験に向き合いたい〜
sansantech
PRO
2
3.4k
AIに「使われる」時代のSaaS戦略 〜既存WebAPIのMCPサーバー化における開発ノウハウ〜
ekispert_api
0
310
型は壁、Rustでもバグを直すな、表現できなくせよ
nwiizo
13
2k
最適な自走を最小限の支援で — M&Aで拡大する組織で少人数SREが挑んだ1年 / SRE NEXT 2026
genda
0
910
AIDLC_ヤフーショッピングの取り組み
lycorptech_jp
PRO
0
600
知らん間に、回ってる
ming_ayami
0
380
金融の未来を考える / Thinking About the Future of Finance
ks91
PRO
0
180
AI Agent SaaS を支える自社仮想化基盤への挑戦と実運用 / ai-agent-saas-virtualization
flatt_security
2
3.6k
Making sense of Google’s agentic dev tools
glaforge
1
130
クラウド上のデータ復旧で見落としがちな制約: 医療系 SaaS の BCP 設計から得た教訓
kakehashi
PRO
0
3.2k
Featured
See All Featured
How to build a perfect <img>
jonoalderson
1
5.8k
Become a Pro
speakerdeck
PRO
31
6k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
72
40k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
Product Roadmaps are Hard
iamctodd
55
12k
Believing is Seeing
oripsolob
1
170
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
220
The browser strikes back
jonoalderson
0
1.4k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.5k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
550
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
260
The Language of Interfaces
destraynor
162
27k
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ؔͷࢿྉ
ͥͻޚࣾͷϏδωε ͝׆༻͍ͩ͘͞ɻ