LESSON 42 OF 52 · CHAPTER 06
Matrix Inference
Matrix/tile construction and matrix-vector multiplication
01-matrix-inference.srp
// Two output scores from two input features.
bind weights = tile([1.0, 2.0, -1.0, 3.0], 2, 2);
bind features = [2.0, 1.0];
print(matvec(weights, features));
stdout
[4.0, 1.0]
Write what you expect this program to print. Check prediction for a line-level hint without revealing the answer, or reveal the verified output when ready. This checks displayed text only; it does not run Scarp or save your input.
UNDERSTAND THE CODE
Explanation & practice
What this example teaches
Matrix/tile construction and matrix-vector multiplication
Expected behavior
[4.0, 1.0]
Practice: Read the source before looking at the output. Predict the values and their order, then use the pinned compiler to execute this lesson and compare the exact fixture. Identify which operation produces the result.
मैट्रिक्स से गणना
tile([1.0, 2.0, -1.0, 3.0], 2, 2) दो गुणा दो का संख्यात्मक ढाँचा बनाता है। matvec(weights, features) वेट और इनपुट फीचर वेक्टर की गणना करता है। यह किसी वास्तविक मॉडल को लोड नहीं करता।
आउटपुट: दो संख्यात्मक स्कोर वाला वेक्टर [4.0, 1.0] मिलता है।
अभ्यास: हाथ से पहली पंक्ति का डॉट प्रोडक्ट 1*2 + 2*1 निकालें।
Explanations are sourced from the project's English chapter guide and हिन्दी अध्याय. The Scarp program and output are unchanged.
SOURCE-BACKED SELF-CHECK · स्रोत-आधारित अभ्यास
Quick checkpoint / त्वरित अभ्यास
What output does matvec(weights, features) produce?matvec(weights, features) का आउटपुट क्या है?
Reveal the source-backed answer / सही उत्तर देखें
[4.0, 1.0] — With rows [1.0, 2.0] and [-1.0, 3.0], multiplying by [2.0, 1.0] gives 4.0 and 1.0.[4.0, 1.0] — मैट्रिक्स की पंक्तियाँ [1.0, 2.0] और [-1.0, 3.0] हैं। इन्हें [2.0, 1.0] से गुणा करने पर 4.0 और 1.0 मिलते हैं।
This question checks understanding of a recorded compiler output. It does not run Scarp in the browser. यह प्रश्न सत्यापित आउटपुट पर आधारित है; ब्राउज़र में Scarp नहीं चलता।
LEARNING PROGRESS
Keep your place
Mark this lesson complete when you are ready.
Only saved in this browser. No account or tracking.
TRY IT LOCALLY
Verify, then execute
Use the pinned compiler from the course root. Keep any imported _support files next to the source.
scarp verify examples/06-ai-foundations/01-matrix-inference.srp
scarp exec examples/06-ai-foundations/01-matrix-inference.srpThe website does not run code. Read the CLI guide ↗
Pinned compiler: Scarp v0.0.6-alpha.3
· ceff07d9014f. No simulated output.