Maida Matrix 3D: Jagora Mai Zurfi
Matrix manipulation wani muhimmin ra'ayi ne a cikin shirye-shiryen kwamfuta da lissafi, kuma matrix na 3D shine nau'in nau'in nau'in nau'in nau'in nau'in nau'in nau'in nau'in nau'in nau'i wanda ke samo aikace-aikace a wurare daban-daban kamar zane-zane na kwamfuta, sarrafa hoto, ฦirar injiniya, da wakilcin bayanai. A cikin wannan labarin, za mu bincika jujjuyawar matrix na 3D, mu fahimci mahimmancinsa, kuma mu koyi aiwatar da shi ta amfani da Python.
Matrix transposition aiki ne da ke jujjuya matrix akan diagonal ษin sa, yana musanya fihirisar layi da ginshiฦi na abubuwa. Don matrix na 3D, wannan aikin zai canza kowane matrix na 2D a ciki, yana haifar da sabon matrix 3D.
Canja wurin Matrix na 3D ta amfani da Python
Don canza matrix na 3D a cikin Python, za mu yi amfani da dabarar madaidaicin madaidaici don daidaita kowane nau'i a cikin matrix. Mun fara da aiwatar da aikin transpose wanda zai karษi matrix na 3D kuma ya dawo da matrix ษin da aka canza.
def transpose(matrix): n, m, l = len(matrix), len(matrix[0]), len(matrix[0][0]) transposed_matrix = [[[0 for _ in range(m)] for _ in range(l)] for _ in range(n)] for i in range(n): for j in range(m): for k in range(l): transposed_matrix[i][k][j] = matrix[i][j][k] return transposed_matrix
Wargaza Code
Bari mu rarraba lambar da ke sama kuma mu fahimci yadda yake aiki mataki-mataki.
1. Mun fara ayyana aikin transpose wanda ke ษaukar matrix 3D azaman shigarwa.
2. Sa'an nan kuma mu lissafta ma'aunin matrix 'n', `m', da `l' na layuka, ginshiฦai, da zurfi, bi da bi.
3. Fara transposed_matrix: Mun ฦirฦiri matrix 3D mara kyau tare da girman da ake buฦata.
4. Muna madauki ta kowane nau'i na matrix na asali ta amfani da madaukai na gida don maido da fihirisa `i`, `j`, da `k`.
5. Fihirisar musaya: Ga kowane kashi, muna musanya ginshiฦi da zurfin fihirisa don samun tasirin canji.
6. A ฦarshe, muna mayar da matrix da aka canza.
Misali Amfani
Yanzu, bari mu yi amfani da aikin mu na transpose zuwa matrix 3D kuma mu hango tsarin jujjuyawa.
# Sample 3D matrix matrix = [ [[1, 2, 3], [4, 5, 6], [7, 8, 9]], [[10, 11, 12], [13, 14, 15], [16, 17, 18]], [[19, 20, 21], [22, 23, 24], [25, 26, 27]] ] transposed = transpose(matrix) print("Original 3D Matrix:") for layer in matrix: print(layer) print("nTransposed 3D Matrix:") for layer in transposed: print(layer)
Takaitaccen Tarihin Ayyukan Matrix
Ayyukan Matrix suna da dogon tarihi a fagen ilimin lissafi, tun daga zamanin da na China da Babila suka waye. Duk da haka, a cikin karni na 19 ne masana lissafin kamar Arthur Cayley da James Joseph Sylvester suka fara tsara ka'idar matrix.
Matrix na 3D, musamman, ya sami kulawa sosai tare da zuwan zane-zanen kwamfuta da fasahar hoto na 3D. Matrix canje-canje ya zama mahimmanci a cikin fassarar, juyawa, da ฦirฦira samfuran dijital a cikin sararin 3D, kuma wannan ya haifar da kewayon ayyuka da dabaru da suka haษa da matrix 3D.
A ฦarshe, wannan labarin yana ba da zurfin fahimtar tsarin jujjuyawar matrix na 3D, aiwatar da shi a Python, da mahimmancinsa a aikace-aikace daban-daban. Fahimtar ayyukan matrix, musamman tare da matrices na 3D, yana taimakawa wajen gina tushe mai ฦarfi a cikin shirye-shiryen kwamfuta da filayen amfani da yawa.