PGDCA, BCA, B-Tech, MCA, M-Tech, B.Sc computer science राजस्थान सूचना सहायक व कंप्यूटर शिक्षक विशेष नोट्स: इस अध्याय में हम 2D Arrays: Column-Major Order (CMO) Address Calculation (2D एरे: कॉलम-मेजर ऑर्डर (CMO) पता गणना और अंतर) की संपूर्ण थ्योरी, मुख्य तकनीकी बिंदु, तुलनात्मक तालिका और विगत परीक्षाओं के पैटर्न पर आधारित 20 अति-महत्वपूर्ण बहुविकल्पीय प्रश्न (MCQs) विस्तृत हिंदी व अंग्रेजी व्याख्या सहित पढ़ेंगे।
Overview: Column-Major Order (CMO) linearizes a 2D matrix by storing all elements of column 0 contiguously in RAM, followed by column 1, column 2, and so forth—the standard layout in Fortran, MATLAB, R, and Julia. Given base B, element width w, total rows M = UR - LR + 1, and lower bounds LR and LC, Loc(A[i][j]) equals B + w * [M * (j - LC) + (i - LR)].
अध्याय सार: कॉलम-मेजर ऑर्डर (CMO) में 2D मैट्रिक्स को मेमोरी में कॉलम-दर-कॉलम (Column-by-Column) सहेजा जाता है, अर्थात पहले पूरा कॉलम 0 और फिर कॉलम 1 लगातार बाइट्स में आता है—यही Fortran, MATLAB, R और Julia का मानक है। यदि बेस B, आकार w, कुल पंक्तियाँ M = UR - LR + 1 और लोअर बाउंड्स LR, LC हों, तो A[i][j] का पता B + w * [M * (j - LC) + (i - LR)] होता है।
2D Arrays: Column-Major Order (CMO) Address Calculation: Detailed Notes & Architecture (2D एरे: कॉलम-मेजर ऑर्डर (CMO) पता गणना और अंतर)
1. Column-by-Column Linearization & Language Standards (Fortran, MATLAB, R) (कॉलम-दर-कॉलम रैखिकीकरण व प्रयुक्त प्रोग्रामिंग भाषाएं)
[EN] In Column-Major Order (CMO), the leftmost (row) index varies fastest: elements down column 0 (A[0][0], A[1][0], ..., A[M-1][0]) occupy consecutive memory bytes before column 1 begins. Scientific and matrix-oriented ecosystems—including Fortran, MATLAB, GNU Octave, R, Julia, and OpenGL matrix stacks—adopt CMO natively. Note that Fortran uses 1-based indexing (LR = 1, LC = 1) by default alongside CMO layout.
[HI] कॉलम-मेजर ऑर्डर (CMO) में बायाँ (पंक्ति) इंडेक्स सबसे तेजी से बदलता है: पहले कॉलम 0 की सभी पंक्तियाँ लगातार मेमोरी में आती हैं और उसके बाद कॉलम 1 शुरू होता है। Fortran, MATLAB, R, Julia तथा OpenGL जैसी वैज्ञानिक भाषाएं व लाइब्रेरी डिफ़ॉल्ट रूप से CMO और उनमें से कई (जैसे Fortran/MATLAB/R) 1-आधारित इंडेक्सिंग उपयोग करती हैं।
2. Exact CMO Formulas: Zero-Based & General Lower/Upper Bounds (सटीक CMO सूत्र: 0-आधारित बनाम सामान्य बाउंड्स (M आधारित))
[EN] For a 0-based M x N matrix A[0..M-1][0..N-1], reaching column j skips j complete columns of M elements each, plus i elements down column j: Loc(A[i][j]) = B + w * (j * M + i). For generalized bounds A[LR..UR][LC..UC], first compute column height M = UR - LR + 1; then Loc(A[i][j]) = B + w * [M * (j - LC) + (i - LR)]. Crucially, CMO depends on total rows M and ignores total columns N.
[HI] 0-आधारित M x N मैट्रिक्स में कॉलम j तक पहुँचने हेतु पहले j पूरे कॉलम (प्रत्येक में M तत्व) और फिर i पंक्तियाँ पार करनी होती हैं: B + w * (j * M + i)। सामान्य बाउंड्स A[LR..UR][LC..UC] में पहले कुल पंक्तियाँ M = UR - LR + 1 निकालें, फिर सूत्र B + w * [M * (j - LC) + (i - LR)] लगाएं। ध्यान रहे कि CMO सूत्र में कुल कॉलम्स N का उपयोग नहीं होता!
3. RMO vs CMO Comparison: Diagonal Identity, Transpose & Coincidence Points (RMO बनाम CMO तुलना: विकर्ण समानता, ट्रांसपोज़ व समान पते वाले तत्व)
[EN] In CMO, vertically adjacent elements A[i][j] and A[i+1][j] sit w bytes apart, whereas horizontally adjacent A[i][j] and A[i][j+1] sit M * w bytes apart—the exact mirror opposite of RMO. Mathematically, storing matrix A in Row-Major Order produces the exact same byte sequence as storing its transpose A^T in Column-Major Order. In a 0-based square N x N matrix, RMO and CMO yield identical addresses along the main diagonal (i == j).
[HI] CMO में एक ही कॉलम के दो पड़ोसी तत्व A[i][j] व A[i+1][j] केवल w बाइट्स दूर होते हैं, जबकि अगले कॉलम A[i][j+1] पर जाने से M * w बाइट्स का अंतर आता है। किसी मैट्रिक्स A का रो-मेजर लेआउट उसके ट्रांसपोज़ A^T के कॉलम-मेजर लेआउट के बिल्कुल समान होता है। 0-आधारित वर्गाकार N x N मैट्रिक्स में मुख्य विकर्ण (i == j) पर RMO और CMO दोनों के पते एक समान होते हैं।
4. Loop Order Performance & Cross-Language Interoperability Traps (लूप ऑर्डर प्रदर्शन और क्रॉस-लैंग्वेज इंटरऑपरेबिलिटी सावधानियाँ)
[EN] Because column neighbors sit side-by-side in CMO, MATLAB, R, and Fortran programs should place the column index j in the OUTER loop and the row index i in the INNER loop so CPU cache lines stream sequentially. When C/Python code passes a Row-Major buffer directly into a Fortran/BLAS/LAPACK Column-Major routine without copying, the routine interprets the buffer as transposed—a classic bug in high-performance computing.
[HI] CMO में कॉलम के तत्व सटे होने के कारण MATLAB या Fortran में बाहरी लूप कॉलम (j) पर और आंतरिक लूप पंक्ति (i) पर चलाना सबसे तेज होता है। यदि C/Python का रो-मेजर मैट्रिक्स बिना रूपांतरण के सीधे Fortran/BLAS जैसी CMO लाइब्रेरी को दिया जाए, तो वह डेटा को ट्रांसपोज़ (Transposed) रूप में पढ़ती है।
Syntax, Formula & Technical Example (2D Arrays: Column-Major Order (CMO) Address Calculation)
// CMO Trace: int A[3][4] (M=3 rows, N=4 cols) at Base=5000, w=4 bytes
// Memory order: A[0][0], A[1][0], A[2][0] (5000..5008), A[0][1], A[1][1]...
// Formula: Loc(A[i][j]) = Base + w * (M * j + i)
// Loc(A[2][1]) in CMO = 5000 + 4 * (3 * 1 + 2) = 5000 + 20 = 5020
// Compare RMO address : 5000 + 4 * (4 * 2 + 1) = 5000 + 36 = 5036 (Different!)
2D Arrays: Column-Major Order (CMO) Address Calculation Quick Reference & Comparison Table
| CMO Parameter / Property | Formula or Specification | Contrast with Row-Major Order |
|---|---|---|
| Zero-Based CMO Formula | B + w * (j * M + i) | Multiplies col j by row count M instead of col count N |
| General CMO Formula | B + w * [M * (j - LC) + (i - LR)] | M = UR - LR + 1 replaces N = UC - LC + 1 |
| Adjacent Memory Neighbors | A[i][j] and A[i+1][j] are w bytes apart | RMO keeps A[i][j] and A[i][j+1] w bytes apart |
| Default Ecosystem Support | Fortran, MATLAB, R, Julia, OpenGL | RMO is default in C, C++, Java, Python NumPy |
2D Arrays: Column-Major Order (CMO) Address Calculation Top 20 Bilingual MCQs with Answers
Q1. How are 2D array elements laid out physically in Column-Major Order (CMO)?
(कॉलम-मेजर ऑर्डर (CMO) में 2D एरे के तत्व मेमोरी में किस प्रकार व्यवस्थित किए जाते हैं?)
(A) Diagonally starting from top-right to bottom-left
(B) Row by row: all elements of row 0 first, followed by row 1
(C) Reverse spiral order from center outward
(D) Column by column: all elements of column 0 first, followed by column 1, column 2, etc.
Correct Answer: (D)
[EN] CMO packs every row entry of column 0 consecutively in 1D memory before storing column 1.
[HI] CMO में पहले कॉलम 0 के सभी तत्व एक के बाद एक सहेजे जाते हैं, फिर कॉलम 1 और उसके बाद कॉलम 2 आता है।
Q2. Which set of programming languages natively uses Column-Major Order for multidimensional arrays?
(निम्नलिखित में से कौन सा भाषा समूह डिफ़ॉल्ट रूप से कॉलम-मेजर ऑर्डर (CMO) का उपयोग करता है?)
(A) C# and Go static arrays
(B) C, C++, and Java
(C) Python NumPy default and Pascal
(D) Fortran, MATLAB, R, and Julia
Correct Answer: (D)
[EN] Fortran, MATLAB, R, and Julia store matrices in Column-Major Order, whereas C, C++, Pascal, and default NumPy use Row-Major Order.
[HI] Fortran, MATLAB, R और Julia कॉलम-मेजर ऑर्डर उपयोग करती हैं, जबकि C, C++, Pascal और डिफ़ॉल्ट NumPy रो-मेजर उपयोग करते हैं।
Q3. Given int A[10][15] at Base = 1000 and w = 4 bytes (0-based), compute the Column-Major address of A[4][6].
(0-आधारित एरे int A[10][15] में बेस 1000 और w = 4 बाइट्स होने पर CMO में A[4][6] का पता क्या होगा?)
(A) 1280
(B) 1240
(C) 1256
(D) 1264
Correct Answer: (C)
[EN] Total rows M = 10. CMO Loc = 1000 + 4 * (10 * 6 + 4) = 1000 + 4 * 64 = 1256 (note RMO was 1264).
[HI] कुल पंक्तियाँ M = 10 हैं। CMO पता = 1000 + 4 * (10 * 6 + 4) = 1000 + 256 = 1256।
Q4. An array A[1..10, 1..20] uses Column-Major Order with Base = 2000 and w = 2 bytes. Find Loc(A[5][12]).
(कॉलम-मेजर एरे A[1..10, 1..20] में बेस एड्रेस 2000 और w = 2 बाइट्स है; A[5][12] का पता क्या होगा?)
(A) 2240
(B) 2228
(C) 2182
(D) 2220
Correct Answer: (B)
[EN] M = 10 - 1 + 1 = 10 rows. Loc = 2000 + 2 * [10 * (12 - 1) + (5 - 1)] = 2000 + 2 * (110 + 4) = 2228.
[HI] M = 10 पंक्तियाँ। पता = 2000 + 2 * [10 * (12 - 1) + (5 - 1)] = 2000 + 2 * 114 = 2228।
Q5. For array A[-2..5, -1..3] in Column-Major Order with Base = 100 and w = 4 bytes, what is Loc(A[2][1])?
(CMO में एरे A[-2..5, -1..3] (Base = 100, w = 4 बाइट्स) के लिए A[2][1] का मेमोरी पता ज्ञात करें।)
(A) 180
(B) 160
(C) 172
(D) 196
Correct Answer: (A)
[EN] M = 5 - (-2) + 1 = 8 rows. Col offset = 1 - (-1) = 2, Row offset = 2 - (-2) = 4. Loc = 100 + 4 * (8 * 2 + 4) = 100 + 80 = 180.
[HI] M = 5 - (-2) + 1 = 8 पंक्तियाँ; कॉलम दूरी = 2 और पंक्ति दूरी = 4। अतः 100 + 4 * (8*2 + 4) = 180।
Q6. Which matrix dimension parameter is NOT required in the Column-Major Order address calculation formula?
(कॉलम-मेजर ऑर्डर के पता गणना सूत्र में किस मान की आवश्यकता बिल्कुल नहीं पड़ती?)
(A) Total number of columns N (or upper column bound UC)
(B) Lower bound of columns LC
(C) Element size w in bytes
(D) Total number of rows M
Correct Answer: (A)
[EN] CMO requires M = UR - LR + 1, LR, LC, Base B, and width w; upper column bound UC / total columns N never enters the formula.
[HI] CMO सूत्र में कुल पंक्तियों M की आवश्यकता होती है, जबकि कुल कॉलम्स N या ऊपरी कॉलम सीमा UC की जरूरत नहीं पड़ती।
Q7. In an M x N array stored in Column-Major Order (width w), what is the byte distance between A[i][j] and A[i][j+1]?
(M x N आकार के कॉलम-मेजर एरे में A[i][j] और A[i][j+1] के बीच कितने बाइट्स का अंतर होता है?)
(A) N * w bytes
(B) M * w bytes
(C) (M - 1) * w bytes
(D) w bytes
Correct Answer: (B)
[EN] Moving horizontally across one column in the same row skips a full column of M elements, i.e., M * w bytes.
[HI] CMO में अगले कॉलम की समान पंक्ति पर जाने के लिए पूरे एक कॉलम के M तत्व पार करने पड़ते हैं, अर्थात M * w बाइट्स।
Q8. In a 0-based square matrix A[n][n], which elements have the EXACT SAME memory address under both RMO and CMO?
(0-आधारित वर्गाकार मैट्रिक्स A[n][n] में किन तत्वों का मेमोरी पता RMO और CMO दोनों में बिल्कुल समान होता है?)
(A) Only A[0][0] and never any other element
(B) All main diagonal elements where i == j
(C) All elements in row 0
(D) All anti-diagonal elements where i + j == n - 1
Correct Answer: (B)
[EN] Equating RMO offset (i*n + j) and CMO offset (j*n + i) yields (i - j)*n = (i - j), which holds for n > 1 if and only if i == j.
[HI] RMO (i*n + j) और CMO (j*n + i) को बराबर रखने पर (जब n > 1 हो) केवल मुख्य विकर्ण i == j के सभी तत्वों का पता एक समान आता है।
Q9. For a non-square 0-based matrix A[3][4], besides A[0][0], which element occupies the identical memory offset in both RMO and CMO?
(गैर-वर्गाकार मैट्रिक्स A[3][4] में A[0][0] के अलावा किस तत्व का पता RMO और CMO दोनों में एक ही होता है?)
(A) A[2][3]
(B) A[1][2]
(C) A[1][1]
(D) A[2][1]
Correct Answer: (A)
[EN] Equating 4*i + j = 3*j + i gives 3*i = 2*j. At i=2, j=3: RMO offset = 4*2 + 3 = 11 and CMO offset = 3*3 + 2 = 11.
[HI] 4*i + j = 3*j + i से 3*i = 2*j मिलता है। i=2, j=3 पर RMO (4*2+3 = 11) और CMO (3*3+2 = 11) दोनों ऑफसेट समान हैं।
Q10. In MATLAB or Fortran (CMO), which nested loop order maximizes spatial cache locality when scanning matrix A[M][N]?
(MATLAB या Fortran (CMO) में मैट्रिक्स A[M][N] को स्कैन करते समय कैश कार्यक्षमता के लिए कौन सा लूप क्रम सर्वश्रेष्ठ है?)
(A) Outer loop over columns j, inner loop over rows i
(B) Traversing backwards from M-1 to 0 in outer loop
(C) Random index permutation loop
(D) Outer loop over rows i, inner loop over columns j
Correct Answer: (A)
[EN] Because column entries A[i][j], A[i+1][j] are adjacent in RAM under CMO, varying the row index i in the inner loop streams memory sequentially.
[HI] CMO में एक कॉलम की पंक्तियाँ सटी होती हैं, इसलिए अंदर के लूप में पंक्ति i (और बाहर कॉलम j) चलाने से क्रमवार कैश हिट मिलता है।
Q11. Storing matrix X in Row-Major Order produces the exact same 1D byte layout as storing which matrix in Column-Major Order?
(किसी मैट्रिक्स X को रो-मेजर ऑर्डर में स्टोर करने पर बनने वाला मेमोरी लेआउट किस मैट्रिक्स के कॉलम-मेजर लेआउट के बराबर होता है?)
(A) X^2 (square of X)
(B) X^(-1) (the inverse of X)
(C) X^T (the transpose of X)
(D) -X (negation of X)
Correct Answer: (C)
[EN] In X^T, entry (j, i) equals X[i][j], so reading X^T column-by-column matches reading X row-by-row.
[HI] ट्रांसपोज़ मैट्रिक्स X^T को कॉलम-दर-कॉलम सहेजना मूल मैट्रिक्स X को पंक्ति-दर-पंक्ति सहेजने के बिल्कुल समान है।
Q12. In Column-Major Order for A[LR..UR, LC..UC] (M = UR - LR + 1), how many elements precede A[i][j]?
(CMO में A[LR..UR, LC..UC] (जहाँ M = UR - LR + 1) के अंदर A[i][j] से ठीक पहले कुल कितने तत्व स्थित होते हैं?)
(A) M * (i - LR) + (j - LC)
(B) N * (i - LR) + (j - LC)
(C) M * (j - LC) + (i - LR)
(D) N * (j - LC) + (i - LR)
Correct Answer: (C)
[EN] There are (j - LC) full columns of height M plus (i - LR) entries down the current column before reaching A[i][j].
[HI] लक्ष्य तत्व से पहले (j - LC) पूरे कॉलम (प्रत्येक में M तत्व) और वर्तमान कॉलम में (i - LR) तत्व होते हैं।
Q13. If A[0..3][0..4] starts at Base = 1000 (w = 4) in CMO, what is the address of A[0][1]?
(यदि A[0..3][0..4] (w = 4) कॉलम-मेजर ऑर्डर में बेस 1000 पर स्थित है, तो A[0][1] का पता क्या होगा?)
(A) 1020
(B) 1012
(C) 1016
(D) 1004
Correct Answer: (C)
[EN] Column 0 has M = 4 rows (indices 0..3): A[0][0]..A[3][0] take 16 bytes (1000..1012), so A[0][1] starts at 1000 + 4*(4*1 + 0) = 1016.
[HI] कॉलम 0 में M = 4 पंक्तियाँ हैं (16 बाइट्स), इसलिए कॉलम 1 का पहला तत्व A[0][1] = 1000 + 4*(4*1 + 0) = 1016 पर होगा।
Q14. What subtle bug happens when passing a raw C Row-Major 2D buffer directly to a Fortran BLAS Column-Major function expecting M x N?
(यदि C के रो-मेजर 2D एरे का बफर बिना बदलाव के सीधे Fortran BLAS (CMO) फंक्शन को दिया जाए तो क्या होगा?)
(A) The CPU automatically swaps row and column caches
(B) Only negative indices break while positive indices match
(C) The Fortran routine interprets the matrix as its transpose (columns become rows)
(D) The C compiler automatically converts RMO to CMO at compile time
Correct Answer: (C)
[EN] Because byte layouts of RMO(A) and CMO(A^T) coincide, a CMO library reading raw RMO bytes sees the transposed matrix.
[HI] RMO और CMO विपरीत होने के कारण CMO लाइब्रेरी उस बफर को मूल मैट्रिक्स के बजाय उसके ट्रांसपोज़ के रूप में पढ़ेगी।
Q15. For a 0-based array A[4][5] (w = 4 bytes), what is the absolute difference |Loc_CMO(A[1][4]) - Loc_RMO(A[1][4])|?
(0-आधारित एरे A[4][5] (w = 4 बाइट्स) में तत्व A[1][4] के लिए कॉलम-मेजर और रो-मेजर पतों के बीच का अंतर |Loc_CMO - Loc_RMO| कितना होगा?)
(A) 48 bytes
(B) 0 bytes
(C) 16 bytes
(D) 32 bytes
Correct Answer: (D)
[EN] RMO offset = 4 * (1 * 5 + 4) = 36 bytes; CMO offset = 4 * (4 * 4 + 1) = 68 bytes; |68 - 36| = 32 bytes.
[HI] RMO ऑफसेट = 4 * (1 * 5 + 4) = 36 बाइट्स; CMO ऑफसेट = 4 * (4 * 4 + 1) = 68 बाइट्स; अंतर = 68 - 36 = 32 बाइट्स।
Q16. Which statement is NOT true regarding Column-Major Order (CMO)?
(कॉलम-मेजर ऑर्डर (CMO) के विषय में इनमें से कौन सा कथन असत्य (NOT true) है?)
(A) The general CMO formula multiplies (j - LC) by total rows M
(B) In CMO, A[i][j] and A[i+1][j] sit side-by-side in memory
(C) C and C++ compilers natively store static 2D arrays in Column-Major Order
(D) Fortran and MATLAB adopt Column-Major Order by default
Correct Answer: (C)
[EN] C and C++ natively store 2D arrays in Row-Major Order (RMO), NOT Column-Major Order.
[HI] C और C++ मूल रूप से रो-मेजर ऑर्डर (RMO) में डेटा स्टोर करते हैं, कॉलम-मेजर में नहीं।
Q17. Within 2D Arrays: Column-Major Order (CMO) Address Calculation, which cmo parameter / property directly maps to: "B + w * (j * M + i)"?
(2D Arrays: Column-Major Order (CMO) Address Calculation में कौन सा CMO Parameter / Property सीधे "B + w * (j * M + i)" से संबंधित है?)
(A) Adjacent Memory Neighbors
(B) Zero-Based CMO Formula
(C) General CMO Formula
(D) Default Ecosystem Support
Correct Answer: (B)
[EN] In 2D Arrays: Column-Major Order (CMO) Address Calculation, 'Zero-Based CMO Formula' handles 'B + w * (j * M + i)' (Multiplies col j by row count M instead of col count N).
[HI] 2D Arrays: Column-Major Order (CMO) Address Calculation में 'Zero-Based CMO Formula' का कार्य/विवरण 'B + w * (j * M + i)' (Multiplies col j by row count M instead of col count N) है।
Q18. Which option accurately describes 'General CMO Formula' in 2D Arrays: Column-Major Order (CMO) Address Calculation?
(2D Arrays: Column-Major Order (CMO) Address Calculation के संदर्भ में 'General CMO Formula' की सही विशेषता कौन सी है?)
(A) B + w * (j * M + i)
(B) Fortran, MATLAB, R, Julia, OpenGL
(C) A[i][j] and A[i+1][j] are w bytes apart
(D) B + w * [M * (j - LC) + (i - LR)]
Correct Answer: (D)
[EN] 'General CMO Formula' provides 'B + w * [M * (j - LC) + (i - LR)]' — key point: M = UR - LR + 1 replaces N = UC - LC + 1.
[HI] 'General CMO Formula' का मुख्य विवरण 'B + w * [M * (j - LC) + (i - LR)]' है (M = UR - LR + 1 replaces N = UC - LC + 1)।
Q19. In 2D Arrays: Column-Major Order (CMO) Address Calculation, identify the correct parameter for the specification: "A[i][j] and A[i+1][j] are w bytes apart".
(2D Arrays: Column-Major Order (CMO) Address Calculation में "A[i][j] and A[i+1][j] are w bytes apart" विवरण किस विकल्प के लिए सही है?)
(A) Zero-Based CMO Formula
(B) Default Ecosystem Support
(C) General CMO Formula
(D) Adjacent Memory Neighbors
Correct Answer: (D)
[EN] 'Adjacent Memory Neighbors' corresponds to 'A[i][j] and A[i+1][j] are w bytes apart' (RMO keeps A[i][j] and A[i][j+1] w bytes apart).
[HI] 'Adjacent Memory Neighbors' का संबंध 'A[i][j] and A[i+1][j] are w bytes apart' (RMO keeps A[i][j] and A[i][j+1] w bytes apart) से है।
Q20. Considering 2D Arrays: Column-Major Order (CMO) Address Calculation, what key behavior defines 'Default Ecosystem Support'?
(2D Arrays: Column-Major Order (CMO) Address Calculation में 'Default Ecosystem Support' की मुख्य भूमिका या मान क्या है?)
(A) B + w * (j * M + i)
(B) A[i][j] and A[i+1][j] are w bytes apart
(C) Fortran, MATLAB, R, Julia, OpenGL
(D) B + w * [M * (j - LC) + (i - LR)]
Correct Answer: (C)
[EN] 'Default Ecosystem Support' represents 'Fortran, MATLAB, R, Julia, OpenGL' (RMO is default in C, C++, Java, Python NumPy).
[HI] 'Default Ecosystem Support' का अर्थ/मान 'Fortran, MATLAB, R, Julia, OpenGL' है (RMO is default in C, C++, Java, Python NumPy)।
2D Arrays: Column-Major Order (CMO) Address Calculation — Exam FAQs
Q1: For a square N x N matrix, which elements sit at the exact same address in both RMO and CMO?
किसी वर्गाकार N x N मैट्रिक्स में किन तत्वों का मेमोरी पता RMO और CMO दोनों में एक ही होता है?
[EN] Every element on the main diagonal (where row index equals column index, i == j) has the identical offset i*(N + 1) in both Row-Major and Column-Major Order.
[HI] मुख्य विकर्ण (Main Diagonal) के सभी तत्व जहाँ i == j होता है, RMO और CMO दोनों में बिल्कुल एक ही मेमोरी पते पर रहते हैं।
Q2: Why is looping j outer and i inner faster in MATLAB and R?
MATLAB और R में बाहरी लूप कॉलम j और आंतरिक लूप पंक्ति i पर चलाना तेज क्यों होता है?
[EN] MATLAB and R store matrices in Column-Major Order, so advancing i in the inner loop steps sequentially through adjacent memory bytes and maximizes CPU cache line reuse.
[HI] MATLAB और R कॉलम-मेजर ऑर्डर उपयोग करते हैं, इसलिए अंदर के लूप में पंक्ति i बदलने पर मेमोरी क्रमिक रूप से पढ़ी जाती है और कैश मिस कम होते हैं।
Q3: Which two values never appear together in the same RMO or CMO formula?
कौन से दो मान एक साथ एक ही RMO या CMO सूत्र में कभी प्रयुक्त नहीं होते?
[EN] Total rows M and total columns N never both appear in a 2D address formula: RMO uses only N (columns per row), whereas CMO uses only M (rows per column).
[HI] कुल पंक्तियाँ M और कुल कॉलम N एक साथ कभी नहीं आते: RMO सूत्र केवल N का और CMO सूत्र केवल M का उपयोग करता है।
Post a Comment
Post a Comment