Öğe Bazında SIMD Matematiği
Tüm vektörleri tek seferde toplayın ve çarpın.
Öğe Bazında SIMD Matematiği, CoddyKit'te ücretsiz bir Mojo Academy dersidir. Bu, 4 dersinin 2. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Mojo Academy öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Mojo Academy kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
Math on Whole Vectors
The best part of SIMD is that arithmetic works on the entire vector at once. One operation touches every lane together.
Adding Two Vectors
Add two SIMD values and each lane is added to its matching lane. This is called element-wise addition.
var a = SIMD[DType.int32, 4](1, 2, 3, 4)
var b = SIMD[DType.int32, 4](10, 20, 30, 40)
var c = a + bLane Lines Up with Lane
In a + b, lane 0 adds to lane 0 and lane 1 adds to lane 1. The lanes never mix, they stay aligned.
print(c[0])Multiplying Vectors
Multiplication is element-wise too. Each lane of one vector is multiplied by the same lane of the other vector.
var p = a * bSubtract and Divide
Subtraction and division follow the same rule. Every lane is handled independently and in parallel across the pack.
var d = b - aScalar Meets Vector
Add a single number to a vector and Mojo applies it to every lane. The scalar spreads across all positions at once.
var bumped = a + 100Widths Must Match
To combine two SIMD values they need the same DType and the same width. Mismatched lane counts will not line up.
Comparisons Go Lane by Lane
Comparing two vectors gives a SIMD of Bools, one True or False per lane. Each lane reports its own result.
var mask = a > SIMD[DType.int32, 4](2)Reducing to One Number
Sometimes you want a single answer. reduce_add sums all lanes into one scalar, perfect for totals.
var total = a.reduce_add()
print(total)Built-in Math Functions
Standard math like sqrt also works lane-wise on SIMD, computing the result for every element in one call.
from math import sqrt
var roots = sqrt(a.cast[DType.float32]())Same Code, Many Results
Writing a + b looks like scalar math but produces many results at once. That readability with speed is Mojo's promise.
Quick Check
You compute a + b where both are SIMD[DType.int32, 4]. How is the addition done?
Recap
Element-wise SIMD math runs +, -, *, and / on every lane at once, scalars spread to all lanes, and reduce_add folds a vector into one number. ✨
Sıkça Sorulan Sorular
“Öğe Bazında SIMD Matematiği” dersi ücretsiz mi?
Evet — “Öğe Bazında SIMD Matematiği” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Mojo Academy kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Mojo Academy kursu toplamda 4 dersten oluşur.
“Öğe Bazında SIMD Matematiği” dersinde ne öğreneceğim?
Tüm vektörleri tek seferde toplayın ve çarpın. Mojo Academy ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
Mojo Academy öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te Mojo Academy, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 2. dersidir.
“Öğe Bazında SIMD Matematiği” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu Mojo Academy dersinde kod yazıp çalıştırabilir miyim?
Evet. Her Mojo Academy dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- SIMD Türüyle Tanışın
- Öğe Bazında SIMD Matematiği
- SIMD Genişliği Seçme
- Bir Döngüyü Vektörleştirme