The invention relates generally to the field of three-dimensional graphic transformation. More particularly, the invention relates to a method and apparatus for inverting a 4×4 matrix within machines capable of performing Single Instruction Multiple Data (SIMD) calculations.
Media applications have been driving microprocessor development for more than a decade. In fact, most computing upgrades in recent years have been driven by media applications, predominantly within consumer segments, but also in enterprise segments for entertainment, enhanced education and communication purposes. Nevertheless, future media applications will require even higher computational requirements. As a result, tomorrow's personal computing (PC) experiences will be even richer in audio/visual effects, as well as being easier to use and more importantly, computing will merge with communications.
Accordingly, the display of images, as well as playback of audio and video, have become increasingly popular for current computing devices. Unfortunately, the quantity of data required for these types of applications tends to be very large. As a result, increases in computational power, memory and disk storage, as well as network bandwidth have facilitated the creation and use of larger and higher quality images. Unfortunately, the use of larger and higher quality images often results in a bottleneck between the processor and memory, as well as requiring intensive computational requirements.
One such media application, which is driving microprocessor development, is three-dimensional (3D) graphics. Specifically, 3D graphics applications provide user users of such systems with enhanced displays, which come close to imitating the clarity provided by real life objects. Unfortunately, 3D graphic systems require intensive computational requirements required for translating objects and coordinates between the various coordinate systems. In fact, transforming a point from one coordinate system to another is one of the most common operations in 3D graphics.
To accomplish transformation of a point from one coordinate system to another in one operation, a 3D point is treated as a four-dimensional (4D) vector [x, y, z, w]. Accordingly, the 3D point may be represented as a 4D vector such that the 3D point is now represented by a homogenous coordinate [x/w, y/w, z/w]. Utilizing such representation, transforming or transferring a point from one coordinate system to another is often accomplished by multiplying the 4D vector by a 4×4 matrix. As a result, the 4×4 matrix represents the transformations, such as scaling, rotation and translation between the two coordinate systems.
Accordingly, a typical 3D pipeline transforms an object from the coordinate system it was created in (objects space) to the world coordinate system (world space) and then to the viewer coordinate system (view space). However, it is quite common that a value defined in the world or view space may require conversion back to its originally created object space. As an example, lights are defined in the world space and are often transformed back to the object space in order to perform light intensity calculations. Generally, this conversion back to the object space is performed by the operation of 4×4 matrix inversion.
Unfortunately, the calculation of a matrix inverse is one of the heaviest operations on matrices. The standard way to calculate an inverse of a matrix is by using a method called “Gaussian Elimination”. However, for small matrices, it is usually more efficient to calculate the inverse by scaling the adjoint matrix by the matrix's determinant residue. Accordingly, scaling the adjoint matrix is the most commonly used implementations by conventional 3D graphic systems.
One of the modern techniques to accelerate numerical calculations is to use Single Instruction Multiple Data (SIMD) algorithms, where each operation is taken over a vector of a few data elements. Unfortunately, the calculation of the adjoint matrix is not easily converted into a SIMD algorithm, as each element in the adjoint matrix is a function of nine of the elements of the source matrix (actually, the determinant of a 3×3 sub-matrix). Furthermore, the calculation over those elements is not easily vectorized. Even when the calculation is vectorized, usually there are not enough registers within the architecture to contain all of the intermediate results.
Therefore, there remains a need to overcome one or more of the limitations in the above-described existing.
The present invention is illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings and in which:
A method and apparatus for inverting a 4×4 matrix are described. In one embodiment, the method includes five stages. During a first stage, a source matrix is divided into four 2×2 sub-matrices. Once sub-divided, a plurality of sub-matrix products are calculated from the four 2×2 sub-matrices. Next, a determinant source matrix is calculated to form a determinant residue (rd) utilizing one or more of the previously computed plurality of sub-matrix products. A calculation of partial inverse for each sub-matrix is next performed, using the one or more of the sub-matrix products. Finally, an inverse of each sub-matrix is calculated, utilizing the partial inverse sub-matrices and determinant reside rd to form an inverse of the 4×4 source matrix.
In the following description, for the purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the present invention. It will be apparent, however, to one skilled in the art that the present invention may be practiced without some of these specific details. In addition, the following description provides examples, and the accompanying drawings show various examples for the purposes of illustration. However, these examples should not be construed in a limiting sense as they are merely intended to provide examples of the present invention rather than to provide an exhaustive list of all possible implementations of the present invention. In other instances, well-known structures and devices are shown in block diagram form in order to avoid obscuring the details of the present invention.
Portions of the following detailed description may be presented in terms of algorithms and symbolic representations of operations on data bits. These algorithmic descriptions and representations are used by those skilled in the data processing arts to convey the substance of their work to others skilled in the art. An algorithm, as described herein, refers to a self-consistent sequence of acts leading to a desired result. The acts are those requiring physical manipulations of physical quantities. These quantities may take the form of electrical or magnetic signals capable of being stored, transferred, combined, compared, and otherwise manipulated. Moreover, principally for reasons of common usage, these signals are referred to as bits, values, elements, symbols, characters, terms, numbers, or the like.
However, these and similar terms are to be associated with the appropriate physical quantities and are merely convenient labels applied to these quantities. Unless specifically stated otherwise, it is appreciated that discussions utilizing terms such as “processing” or “computing” or “calculating” or “determining” or “displaying” or the like, refer to the action and processes of a computer system, or similar electronic computing device, that manipulates and transforms data represented as physical (electronic) quantities within the computer system's devices into other data similarly represented as physical quantities within the computer system devices such as memories, registers or other such information storage, transmission, display devices, or the like.
The algorithms and displays presented herein are not inherently related to any particular computer or other apparatus. Various general purpose systems may be used with programs in accordance with the teachings herein, or it may prove convenient to construct more specialized apparatus to perform the required method. For example, any of the methods according to the present invention can be implemented in hard-wired circuitry, by programming a general-purpose processor, or by any combination of hardware and software.
One of skill in the art will immediately appreciate that the invention can be practiced with computer system configurations other than those described below, including hand-held devices, multiprocessor systems, microprocessor-based or programmable consumer electronics, digital signal processing (DSP) devices, network PCs, minicomputers, mainframe computers, and the like. The invention can also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. The required structure for a variety of these systems will appear from the description below.
It is to be understood that various terms and techniques are used by those knowledgeable in the art to describe communications, protocols, applications, implementations, mechanisms, etc. One such technique is the description of an implementation of a technique in terms of an algorithm or mathematical expression. That is, while the technique may be, for example, implemented as executing code on a computer, the expression of that technique may be more aptly and succinctly conveyed and communicated as a formula, algorithm, or mathematical expression.
Thus, one skilled in the art would recognize a block denoting “C=A+B” as an additive function whose implementation in hardware and/or software would take two inputs (A and B) and produce a summation output (C). Thus, the use of formula, algorithm, or mathematical expression as descriptions is to be understood as having a physical embodiment in at least hardware and/or software (such as a computer system in which the techniques of the present invention may be practiced as well as implemented as an embodiment).
In an embodiment, the methods of the present invention are embodied in machine-executable instructions. The instructions can be used to cause a general-purpose or special-purpose processor that is programmed with the instructions to perform the steps of the present invention. Alternatively, the steps of the present invention might be performed by specific hardware components that contain hardwired logic for performing the steps, or by any combination of programmed computer components and custom hardware components.
In one embodiment, the present invention may be provided as a computer program product which may include a machine or computer-readable medium having stored thereon instructions which may be used to program a computer (or other electronic devices) to perform a process according to the present invention. Accordingly, the computer-readable medium includes any type of media/machine-readable medium suitable for storing electronic instructions. Moreover, the present invention may also be downloaded as a computer program product. As such, the program may be transferred from a remote computer (e.g., a server) to a requesting computer (e.g., a client). The transfer of the program may be by way of data signals embodied in a carrier wave or other propagation medium via a communication link (e.g., a modem, network connection or the like).
System
Referring to
Furthermore, a data storage device 107, such as a magnetic disk or optical disk, and its corresponding disk drive, can be coupled to computer system 100. Computer system 100 can also be coupled via bus 101 to a display device 121 for displaying information to a computer user. Display device 121 can include a frame buffer, specialized graphics rendering devices, a cathode ray tube (CRT), and/or a flat panel display. An alphanumeric input device 122, including alphanumeric and other keys, is typically coupled to bus 101 for communicating information and command selections to processor 109.
Another type of user input device is cursor control 123, such as a mouse, a trackball, a pen, a touch screen, or cursor direction keys for communicating direction information and command selections to processor 109, and for controlling cursor movement on display device 121. This input device typically has two degrees of freedom in two axes, a first axis (e.g., x) and a second axis (e.g., y), which allows the device to specify positions in a plane. However, this invention should not be limited to input devices with only two degrees of freedom.
Another device which may be coupled to bus 101 is a hard copy device 124 which may be used for printing instructions, data, or other information on a medium such as paper, film, or similar types of media. Additionally, computer system 100 can be coupled to a device for sound recording, and/or playback 125, such as an audio digitizer coupled to a microphone for recording information. Further, the device may include a speaker which is coupled to a digital to analog (D/A) converter for playing back the digitized sounds.
Also, computer system 100 can be a terminal in a computer network (e.g., a LAN). Computer system 100 would then be a computer subsystem of a computer system including a number of networked devices. Computer system 100 optionally includes video digitizing device 126. Video digitizing device 126 can be used to capture video images that can be transmitted to others on the computer network.
Computer system 100 is useful for supporting computer supported cooperation (CSC—the integration of teleconferencing with mixed media data manipulation), 2D/3D graphics, image processing, video compression/decompression, recognition algorithms and audio manipulation.
Processor
Depending on the type of data, the data may be stored in integer registers 201, registers 209, registers 215, floating point registers 213, status registers 208, or instruction pointer register 211. In one embodiment, integer registers 201 store thirty-two bit integer data. In one embodiment, registers 209 contains eight multimedia registers, R1212-1 through R8212-8, for example, single instruction, multiple data (SIMD) registers containing packed floating point data. Each register in registers 209 is one hundred twenty-eight bits in length. R1212-1, R2212-2 and R3212-3 are examples of individual registers in registers 209.
In one embodiment, registers 215 contains eight multimedia registers, R1216-1 through R8216-8, for example, single instruction multiple data (SIMD) registers containing packed floating point data. Each register in registers 215 is sixty-four bits in length. R1216-1, R2216-2 and R3216-3 are examples of individual registers in registers 215. Status registers 208 indicate the status of processor 109. Instruction pointer register 211 stores the address of the next instruction to be executed. Integer registers 201, registers 209, status registers 208, and instruction pointer register 211 all connect to internal bus 205. Any additional registers would also connect to the internal bus 205.
In another embodiment, some of these registers can be used for different types of data. For example, registers 209 and integer registers 201 can be combined where each register can store either integer data or packed data. In another embodiment, registers 209 can be used as floating point registers. In this embodiment, packed data or floating point data can be stored in registers 209. In one embodiment, the combined registers are one hundred twenty-eight bits in length and integers are represented as one hundred twenty-eight bits. In this embodiment, in storing packed data and integer data, the registers do not need to differentiate between the two data types.
Functional unit 203 performs the operations carried out by processor 109. Such operations may include shifts, addition, subtraction and multiplication, etc. Functional unit 203 connects to internal bus 205. Cache 206 is an optional element of processor 109 and can be used to cache data and/or control signals from, for example, main memory 104. Cache 206 is connected to decoder 202, and is connected to receive control signal 207.
Data and Storage Formats
Referring now to
Packed word 222 is one hundred twenty-eight bits long and contains eight packed word data elements. Each packed word contains sixteen bits of information. Packed doubleword 223 is one hundred twenty-eight bits long and contains four packed doubleword data elements. Each packed doubleword data element contains thirty-two bits of information. A packed quadword 224 is one hundred twenty-eight bits long and contains two packed quad-word data elements. Thus, all available bits are used in the register. As a result, this storage arrangement increases the storage efficiency of the processor. Moreover, with multiple data elements accessed simultaneously, one operation can now be performed on multiple data elements simultaneously.
Accordingly, an entire sub-matrix may be stored utilizing two 128-bit registers, each containing two vector elements which are stored in packed double precision floating-point format. Packed byte integers 232 illustrate the storage of 16 packed integers, while packed word integers 233 illustrate the storage of 8 packed words. Finally, packed doubleword integers 234 illustrate the storage of four packed doublewords, while packed quadword integers 235 illustrate the storage of two packed quadword integers within a 128-bit register, for example as depicted in
Referring now to
Referring now to
As will be described in further detail below, packed single precision floating-point 252 may be utilized to store two elements of a 2×2 sub-matrix such that the entire sub-matrix may be stored utilizing two 64-bit registers, each containing two vector elements which are stored in packed single precision floating-point format.
Matrix Inversion
As described above, 3D graphics provides an extremely popular technology, which provides users with real-life depiction of graphic objects which often imitate real-life. Unfortunately, 3D graphics systems require intensive computational requirements required for translating objects and coordinates between various coordinate systems. In fact, transforming a point from one coordinate system to another is one of the most important operations in 3D graphics. To accomplish transformation of one point from one coordinate system to another in one operation, a 3D point is treated as a four-dimensional (4D) vector [x, y, z, w]. Accordingly, the 3D point may be represented as a 4D vector such that the 3D point is now represented by homogenous coordinate [x/w, y/w, z/w].
A 3D pipeline, which is often utilized by 3D graphic systems, transforms an object from one coordinate system it was created in (object space) to the world coordinate system (world space) and then to the viewer coordinate system (view space). However, it is quite common that a value defined in the world or view space may require conversion back to its original created object space. As an example, lights are defined in the world space and are often transformed back to the object space in order to perform light intensity calculations. Generally, this conversion back to the object space is performed utilizing a 4×4 matrix inversion operation.
Unfortunately, the calculation of the matrix inverse is one of the more intensive operations performed on matrices. A standard way to calculate an inverse of the matrix by using a method called “Gaussian Elimination”. For small matrices, it is usually more efficient to calculate the adjoint matrix and divide by the matrix's determinant. Accordingly, adjoint scaling is of the most commonly used implementations by conventional 3D graphic systems.
However, the calculation of the adjoint matrix is not easily converted into an algorithm utilizing the single instruction multiple data (SIMD) operators, as each element of the adjoint matrix is a function of nine of the elements from the source matrix (actually, the determinant of a 3×3 sub-matrix). Furthermore, those elements are not readily placed within a sequential order in memory, and consequentially, are not easily vectored for SIMD operations. Even when the calculation is finally vectorized, usually there are not enough registers within the architecture to contain all of the intermediate results.
Accordingly, the present invention describes a method of inverting a 4×4 source matrix using a sub-division technique which achieves improved computational locality when utilizing single instruction multiple data implementations. As such, utilizing the following equations, a 4×4 inverse matrix is divided into four inverse sub-matrices, iA, iB, iC and iD, and can be calculated directly from the four sub-matrices of the source matrix (A, B, C and D) according to the following equations:
iA=adj(A·|D|−B·adj(D)·C)/dS (1)
iB=adj(C·|B|−D·adj(B)·A)/dS (2)
iC=adj(B·|C|−A·adj(C)·D)/dS (3)
iD=adj(D·|A|−C·adj(A)·B)/dS (4)
where dS is the determinant of the source matrix. The determined 4×4 matrix dS can be calculated by the following formula
dS=det(Src)=|A|·|D|+|B|·|C|−trace(adj(A)·B·adj(D)·C) (5)
Hence, utilizing the equations described above, the calculation of the adjoint matrix (for a 2×2 sub-matrix) requires two sign changes.
The sign inversion can be hidden in prior or subsequent calculations (i.e., when we use the adjoint matrix for the formation of a matrix product as described below). Therefore, the calculation of the adjoint matrix demands practically zero computation.
The terms adj(D)·C and adj(A)·B appear in Equation 5 and in Equations 1 and 4. Accordingly, they do not require recalculation. In addition, for the multiplication between adj(D)·C and adj(A)·B in Equation 5, the calculation of the two elements is not required, as the trace of a matrix is the sum of the diagonal elements. As such, four products, rather than eight products, are actually required to calculate the trace in trace ((adj(A)·B)·(adj(D)·(C)). Finally, in Equations 2 and 3, calculation of adj(B)·A and adj(C)·D are required. However, since we are using 2×2 sub-matrices, those values are given immediately from adj(A)·B and adj(D)·C as follows:
adj(B)·A=adj(adj(A)·B) (7)
adj(C)·D=adj(adj(D)·C) (8)
As such, utilizing the matrix sub-division technique as described, the calculation of the matrix inverse results in a faster computation speed. In comparison to a prior art implementation, the single instruction multiple data (SIMD) implementation described herein is about 40% faster than the standard implementation. Since the described method has better computational locality, even a scalar implementation of the method herein is faster than a prior art implementation. Accordingly, one embodiment will be described herein for implementation of the Equations 1–5 utilizing 128-bit double-precision floating-point registers, as depicted in
Accordingly, referring now to
As depicted in
Block Diagrams
Referring now to
Referring again to
In one embodiment, a shuffle operation is performed to transpose the elements within register 212-2 such that X22 is now a first element 212-2a of the register 212-2 and X21 is now a second element 212-2b of the register 212-2. Once shuffled, a multiplication operation 406 is performed with the result of the multiplication operation stored in the register 212-4. Next, a shuffle operation is used in order to copy a second element 212-4b of the product into the first element 215-5A of register 212-5. Finally, a scalar subtraction operation 408 is performed utilizing register 212-4 and 212-5 in order to generate the determinant value 402, which is stored in register 212-6.
As illustrated by
Referring now to
Following the shuffling, a multiplication operation 418 is performed utilizing registers 212-5 and 212-1 with the result of the multiplication stored in register 212-7. Simultaneously, a multiplication operation 420 is performed utilizing register 212-6 and 212-1 with the results stored in register 212-8. Finally, an addition operation 422 is performed utilizing registers 212-7 and 212-8 to produce the result 422, which is stored in register 212-3. Accordingly, the result generated represents a first portion of the matrix multiplication operation 410, which is stored in vector 1 (V1) 422 of the result XY.
Concurrent with the calculation of the first row of the matrix multiplication operation 410, a register 212-3 is loaded with the second row of the sub-matrix X. Once loaded, the elements of register 212-3 are shuffled utilizing registers 212-3 and 212-4, such that registers 212-3 and registers 212-4 include duplicate pairs of the elements X21 and X22, respectively. Next, a multiplication operation 424 is performed of registers 212-5 and 212-3 in order to generate a result which is stored in register 212-1. Concurrently, register 212-6 is multiplied with register 212-4 with the result of the multiplication operation 426 stored in register 212-2. Finally, an addition operation 428 is performed in order to generate the second row of the matrix products, which is stored in register 212-4. As such, the multiplication operation result XY 412 is stored within a pair of registers 212-3 and 212-4, which are referenced by providing parameter V1 for register 212-3 or V2 for register 212-4.
Referring now to
Once the data is expanded, a multiplication operation 438 is performed utilizing registers 212-1 and 212-5 with a result of the operation stored in register 212-7. Concurrently, a multiplication operation 440 is performed utilizing registers 212-2 and 212-6, with the result stored in register 212-8. Finally, a subtraction operation 442 is performed utilizing the contents of registers 212-7 and 212-8, with the results stored in register 212-3. As such, register 212-3 stores the first row of the result sub-matrix {tilde over (X)}Y 434.
Following storage of the values, a multiplication operation 444 is performed utilizing registers 212-5 and 212-3, with the result of the operation stored in register 212-1. Concurrently, a multiplication operation 446 is performed utilizing vectors 212-4 and 212-6, with the results stored in register 212-5. Finally, a subtraction operation 448 is performed utilizing vectors 212-2 and 212-1, with a result of the operation 436 stored in register 212-2. As such, now the register stores the second row of the result sub-matrix {tilde over (X)}Y. Accordingly, the result of the matrix adjoint multiplication operation 440 is stored in registers 212-3 and 212-4.
Referring now to
Concurrently, first row of sub-matrix X 451 is stored in register 212-1, while the elements of the first row element pair are transposed and stored in register 212-5. Concurrently, the second row of sub-matrix X 451 are stored in register 212-2, while the transposed version of the elements are transposed and stored in register 212-6.
Next, a multiplication operation 458 is performed utilizing registers 212-1 and 212-3, with a result of the operation stored in register 212-7. Concurrently, a multiplication operation 460 is performed utilizing registers 212-4 and 212-5, with a result of the operation stored in register 212-8. Next, a subtraction operation 462 is performed utilizing registers 212-7 and 212-8, with a result of the operation stored in register 212-3. As such, register 212-3 will contain a first row 454 as a result of the matrix multiplication operation 450 X{tilde over (Y)}.
Concurrently, a multiplication operation 464 will be performed utilizing the contents of registers 212-2 and 212-3, with the results stored in register 212-1. Concurrently, a multiplication operation 466 will be performed utilizing the contents of register 212-4 and 212-6, with the result of the operation stored in register 212-5. Finally, a subtraction operation 468 will subtract the contents of register 212-5 from register 212-1, with a result of the operation stored in register 212-2. As a result, a second row of the matrix multiplication operation 450 will be stored in register 212-2, such that the final result of the matrix multiplication operation 452 is stored as two rows 452 and 454, which are contained in registers 212-3 and 212-2.
Referring now to
Next, the first and second rows of sub-matrix Y 473 are stored in registers 212-7 and 212-8. Once stored, a subtraction operation 478 is performed utilizing the contents of registers 212-5 and 212-7, with a result of the subtraction operation 478 stored in register 212-2. Concurrently, a second subtraction operation 479 is performed utilizing the contents of registers 212-6 and 212-8, with a result of the subtraction operation stored in register 212-4. Accordingly, the matrix scaling operation result 472 is stored as two rows, which are stored in registers 212-2 and 212-4, with corresponding results Z.V1472-1 and Z.V2472-1 for selecting the result 472.
Referring now to
Once stored, a multiplication operation 481 is performed utilizing the contents of registers 212-2 and 212-3, with a result of the operation 481 stored in register 212-5. Concurrently, a multiplication operation 482 is performed utilizing the contents of registers 212-2 and 212-4, with a result of the multiplication operation 482 stored in register 212-6. Next, an addition operation 483 is performed utilizing the contents of registers 212-5 and 212-6, with a result of the addition operation stored in register 212-7. Once stored, the second element 212-7a of register 212-7 is stored as the first element 212-8a of register 212-8. Next, a scalar addition operation 484 is performed utilizing the contents of registers 212-7 and 212-8 to form a trace value t=trace(X·Y) [=trace(ÃB·{tilde over (D)}C)], which is stored as a first vector element 212-1a in register 212-1.
Concurrently, a determinant of each sub-matrix (dA, dB, dC, dD ) is stored as a first element vector within registers 212-1, 212-2, 212-3 and 212-4, respectively. Concurrently, a scalar multiplication operation 485 is performed utilizing the contents of registers 212-1 and 212-2, with the results stored as the first element 212-5a of register 212-5. Concurrently, a scalar multiplication operation 486 is performed utilizing the contents of registers 212-3 and 212-4, with a result of the scalar multiplication operation 486 stored in register 212-6. Next, a scalar additional operation 487 is performed utilizing the first element of registers 212-5 and 212-6, with a result of the operation stored in register 212-2.
Next, a scalar subtraction operation 488 is performed utilizing the first element 212-2a of register 212-2 and the first element 212-1a of register 212-1, to form the value of dS=det(Src)=|A|·|D|+|B|·|C|−t stored as the first element 212-4a of register 212-4. Next, a value of one is stored as the first element 212-3a of register 212-3, such that a scalar division operation 489 is performed utilizing a first element of registers 212-2 and 212-1. A result of the scalar division operation 489 is stored as the first element 212-4a of register 212-4 to form the determinant residue rd=1/dS value 480.
Finally, referring to
Next, a multiplication operation 492 is performed utilizing the contents of registers 212-1 and 212-3 to form the residue value (rd) and a negative residue value (−rd), which are stored as the first element 212-7a and the second element 212-7b of register 212-7. Concurrently, another multiplication operation 494 is performed utilizing the contents of registers 212-2 and 212-4 to form a negative residue value (−rd) and a positive residue value (+rd), which are stored as the first element 212-8a and the second element 212-8b of register 212-8. The two registers 212-7 and 212-8 can be kept aside for future use.
Depending on the processor, using an exclusive OR (XOR) operation instead of a multiplication operator may be faster. In this case, the multiplication operators 492 and 494 should be replaced with XOR operators. However, for XOR operator to change the sign bit, contents of registers 212-3 and 212-4 should be all zeros, except for the most significant bits of 212-3b and 212-4a, which represent the sign bit when using IEEE floating-point numbers, set to 1.
Next, the first elements X11 and X12 of sub-matrix X 493 are stored in register 212-5 while the second row element vector pair A21 and A22 are stored in register 212-6. Once stored, the values are transposed using a shuffle operation such that X22 and X12 are stored in register 212-5, while X21 and X11 are stored in register 212-6. Next, a multiplication operation 496 is performed utilizing the contents of registers 212-5 and 212-17, with a result of the operation 496 stored in register 212-3. Concurrently, a multiplication operation 498 is performed utilizing the contents of registers 212-6 and registers 212-8, with a result of the operation 498 stored in register 212-4. Accordingly, the scaled adjoint adj(X)·rd result is stored within register 212-3 and 212-4. Procedural methods for implementing the teachings of the present invention are now described.
Operation
Referring now to
At process block 502, the source matrix 300 is divided into four 2×2 sub-matrices, A, B, C and D, as depicted in
Next, at process block 520, a determinant of the source matrix (dS) is calculated utilizing Equation 5. Equation 5 uses the determinants of the four sub-matrices (dA, dB, dC and dD) and two intermediate sub-matrix products (adj(A)·B and adj(D)·C) of the plurality of sub-matrix products previously calculated at process block 504. The flowchart for process block 520 is further depicted in
Next, at process block 540, partial inverse is calculated for each sub-matrix (pA, pB, pC and pD). In one embodiment, the partial inverse sub-matrices are constructed utilizing the sub-matrix determinants and the final sub-matrix products previously calculated at process block 504. The flowchart for process block 540 is further depicted in
The flowchart for process block 570 is further depicted in
Referring now to
{tilde over (D)}C=adj(D)·C
ÃB=adj(A)·B
{tilde over (B)}A=adj(ÃB)[=adj(B)·A]
{tilde over (C)}D=adj({tilde over (D)}C)[=adj(C)·D] (9)
In one embodiment, the intermediate sub-matrix products within Equation 9 are calculated utilizing sub-matrix row representations as depicted in
B{tilde over (D)}C=B·{tilde over (D)}C
D{tilde over (B)}A=D·adj(ÃB)[=D·{tilde over (B)}A]
A{tilde over (C)}D=A·adj({tilde over (D)}C)[=A·{tilde over (C)}D]
CÃB=C·ÃB (10)
In one embodiment, calculating of the sub-matrix products operator of Equation 10 for the final sub-matrix products is performed utilizing the vector representation as depicted in
Referring now to
t=trace(ÃB·{tilde over (D)}C) (11)
Finally, at process block 528, a determinant value dS of the source matrix is computed by performing the following equation:
dS=dA·dD+dB·dC−t (12)
Accordingly, at process block 530 (
Referring now to
pA=A*dD−B{tilde over (D)}C
pB=C*dB−D{tilde over (B)}A
pC=B*dC−A{tilde over (C)}D
pD=D*dA−CÃB (13)
In one embodiment, those calculations are performed in accordance with the matrix scaling operation 470, as depicted in
Referring now to
iA=adj(pA)
iB=adj(pB)
iC=adj(pC)
iD=adj(pD) (14)
Once calculated, at process block 576 a final inverse value is computed according to the following equations by scaling each sub-matrix calculated at process block 574 by the determinant residue.
iA=iA*rd[=adj(pA)*rd]
iB=iB*rd[=adj(pB)*rd]
iC=iC*rd[=adj(pC)*rd]
iD=iD*rd[=adj(pD)*rd] (15)
Accordingly, once the final inverse values of each sub-matrix are calculated at process block 576, the inverse of the source matrix iS is formed according to the following rule:
Accordingly, as in one embodiment, the calculation of the inverse of a source matrix is performed by sub-dividing the source matrix into four sub-matrices. This enables storage of each of the rows of a sub-matrix within a single SIMD register. As such, concurrent calculation of the various matrix products, determinants, scaling and residue provides improved efficiency when calculating the inverse of a source matrix. This follows due to the fact that the inverse of each sub-matrix is recombined to form the inverse of the source matrix 300 in accordance with Equation 16.
The scaling of the sub-matrices in Equation 15 and process block 576 can be done in earlier stages with less operations. Referring now to
Referring now to
At process block 620, the sub-matrix determinants and the intermediate sub-matrix products are scaled using the determinant residue to form final sub-matrix products. Next, at process block 630, a partial inverse sub-matrix is formed for each sub-matrix using the scaled sub-matrix determinants and the final sub-matrix products. Finally, at process block 640, an inverse of each sub-matrix, iA, iB, iC and iD, is calculated utilizing each partial inverse sub-matrix to form an inverse of the source matrix iS.
Referring now to
Referring now to
Once each of the intermediate sub-matrix products is scaled by the determinant residue at process block 626, process block 628 is performed. At process block 628, the final sub-matrix products are formed according to the following equations:
B{tilde over (D)}C=B·{tilde over (D)}C;
D{tilde over (B)}A=D·adj(ÃB);
A{tilde over (C)}D=A·adj({tilde over (D)}C); and
CÃB=C·ÃB.
Accordingly, in contrast to the method described with reference to
Referring to
pA=A*dD−B{tilde over (D)}C
pB=C*dB−D{tilde over (B)}A
pC=B*dC−A{tilde over (C)}D
pD=D*dA−CÃB (17)
Finally, referring to
Alternate Embodiments
Several embodiments of the matrix inversion process for providing vector transformations have been described. However, various implementations of the matrix inversion process provide numerous features including, complementing, supplementing, and/or replacing the features described above. Features can be implemented as part of an ALU, a programmed device, or as part of a software library in different implementations. In addition, the foregoing embodiments, for purposes of explanation, used specific nomenclature to provide a thorough understanding of the invention. However, it will be apparent to one skilled in the art that the specific details are not required in order to practice the embodiments described herein.
In addition, although an embodiment described herein is directed to software implement matrix inversion processes, it will be appreciated by those skilled in the art that the teaching of the present invention can be applied to other systems. In fact, systems for vector transformations utilizing SIMD operations are within the teachings of the present invention, without departing from the scope and spirit of the present invention. The embodiments described above were chosen and described in order to best explain the principles of the invention and its practical applications. These embodiment were chosen to thereby enable others skilled in the art to best utilize the invention and various embodiments with various modifications as are suited to the particular use contemplated.
It is to be understood that even though numerous characteristics and advantages of various embodiments have been set forth in the foregoing description, together with details of the structure and function of various embodiments of the invention, this disclosure is illustrative only. In some cases, certain subassemblies are only described in detail with one such embodiment. Nevertheless, it is recognized and intended that such subassemblies may be used in other embodiments of the invention. Changes may be made in detail, especially matters of structure and management of parts within the principles of the present invention to the full extent indicated by the broad general meaning of the terms in which the appended claims are expressed.
Having disclosed exemplary embodiments and the best mode, modifications and variations may be made to the disclosed embodiments while remaining within the scope of the invention as defined by the following claims.
Number | Name | Date | Kind |
---|---|---|---|
5557511 | Bayard | Sep 1996 | A |
6748098 | Rosenfeld | Jun 2004 | B1 |
Number | Date | Country | |
---|---|---|---|
20030126176 A1 | Jul 2003 | US |