Optical computing harnesses the speed of light to perform vector-matrix operations efficiently. It leverages interference, a cornerstone of quantum computing algorithms, to enable parallel computations. In this work, we interweave quantum computing with classical structured light by formulating the process of photonic matrix multiplication using quantum mechanical principles such as state superposition and subsequently demonstrate a well-known algorithm, namely, Deutsch–Jozsa’s algorithm. This is accomplished by elucidating the inherent tensor product structure within the Cartesian transverse degrees of freedom of light, which is the main resource for optical vector-matrix multiplication. To this end, we establish a discrete basis using localized Gaussian modes arranged in a lattice formation and demonstrate the operation of a Hadamard gate. Leveraging the reprogrammable and digital capabilities of spatial light modulators, coupled with Fourier transforms by lenses, our approach proves adaptable to various algorithms. Therefore, our work advances the use of structured light for quantum information processing.

## I. INTRODUCTION

Controlling various degrees of freedom of light, i.e., time, frequency, space, and momentum, has become an emerging and promising tool for numerous information processing tasks in classical and quantum domains, ranging from novel imaging methods^{1–7} to communications^{8–13} to computations,^{14–17} all harnessing the high dimensional nature of structured light fields.^{18–22} This is because spatial modes enable information encoding in qudit spaces for dimensions *d* > 2 per particle as opposed to the *d* = 2 (qubits) encoding levels offered by traditional qubit encoding, such as with polarization states. Because qubits are easy to control, they are a reliable resource for numerous protocols.

In traditional quantum computing, encoding basis states are typically formed from multiple qubits, and the operations needed to construct arbitrary unitary gates in *d* > 2 dimensions often involve a mix of two-dimensional gate operations (such as the Hadamard gate and T-gate) along with multi-qubit operations (such as the Control-not gate).^{23} This allows for precise and efficient execution of arbitrary computations that are required to demonstrate quantum advantage.^{24} Given that each qubit is restricted to two dimensions, the only way to enhance encoding capacity is by increasing the number of qubits and ensuring optimal connectivity among them. An alternative is to utilize qudits, which are particles that occupy *d* > 2 dimensions because they offer larger encoding state spaces^{25} and promise robustness against noise.^{26} As a result, structured photon states emerge as a promising candidate for achieving this, as they occupy higher-dimensional Hilbert spaces. Furthermore, it has been demonstrated that vector-matrix multiplication, a fundamental operation in quantum mechanics, can be performed using transverse optical fields.^{27}

There have been numerous impressive proposals and implementations of quantum computing algorithms that utilize the higher dimensional nature of the internal degrees of freedom of photons.^{28–30} This field has developed tremendously, aided by the advent of multiplane light conversion technology,^{31} where digital holography and free-space diffraction are employed to realize arbitrary unitary gate operations.^{32} Inspired by these advances, diffraction-based deep neural network architectures have also been proposed.^{33} In addition, harnessing mode mixing in complex media such as multimodal optical fibers, as opposed to diffractive MPLCs, has emerged as a potential avenue (see review on this topic^{34}) to achieve similar operations but with discrete pixel-like states.^{35} To realize the full potential of qudits for quantum computing, efficient single photon sources and the tools for entangling and controlling them are necessary.

On the other hand, harnessing classical optical fields for quantum computing has also been an active area of research.^{14,36–40} The drive in this field has been inspired by the observation that some of the essential resources of quantum computing can be found in classical coherent fields. Similar to quantum states, classical waves can be prepared in superpositions and can be interfered with, allowing for parallel information processing. Notably, Jozsa also argued that classical waves can provide an efficient simulation platform since not all quantum algorithms require entanglement as a resource.^{41,42} Recent advances have demonstrated that optical methods can implement unitary and nonunitary transformations efficiently, utilizing programmable holographic techniques and spatial phase modulation to enable high-dimensional operations.^{43} Similarly, parallel processing for computational tasks such as multiplication modulo, a crucial component of Shor’s algorithm, using phase modulation has been explored, offering promising avenues for structured light applications in computational tasks.^{44} This opens up new possibilities for studying or implementing quantum computational tasks without relying on complex quantum hardware by merely exploiting coherent fields and performing the required matrix-vector operations on them.

An intriguing and unexplored approach to utilizing coherent fields in quantum computing is Tamura’s optical matrix-vector multiplication from the 1970s,^{45} which was long forgotten but has recently resurfaced. This method harnesses point-wise multiplication (Hadamard product) of light and the Fourier transform capabilities of lenses. With this approach, operations have been applied in dimensions reaching up to *d* = 56 dimensions.^{27} Hidden in this method is the capability to encode information in Hilbert spaces formed from transverse modes of coherent laser fields.

In this work, we use optical matrix multiplication as a foundation for emulating quantum algorithms, therefore interacting quantum computing with structured light. We unveil the inherent tensor product structure of transverse spatial modes that is exploited in coherent optical matrix-vector multiplication and show that it can be harnessed as a tool to emulate quantum computing algorithms. Our logical basis is constructed from lattices of displaced Gaussian modes, eigenmodes of free space, that are locally modulated with digital holograms encoded on spatial light modulators. We treat the Cartesian location coordinates *x* and *y* of each mode as our degrees of freedom, forming the equivalent of two qudit registers. The *x* component is used to embed our state vectors, while the *y*-component acts as an ancilla that facilitates the unitary gate operator implementation. After a cylindrical lens integrates over the *x*-component, the final resulting state is measured in the *y*-coordinate. We test this using our basis and the Hadamard transform as example, and demonstrate the Deutsch–Jozsa algorithm with our encoding scheme, showing it can be used to query balanced and constant functions with average fidelity above 90%. In our scheme, we exploit the inherent parallelism offered by optical matrix-vector multiplication, allowing to prepare multiple identical spatial modes as a superposition and encode the oracle matrix as local phase transformations on each state.

## II. THEORY

### A. Matrix-vector multiplication via point-wise multiplication

*M*, with elements

*M*

_{jk}, and a vector

*u*with elements

*u*

_{k}. We can compute the matrix-vector product to produce the vector

*v*≡

*Mu*, where the

*j*th component can be computed from

*v*

_{j}=

*∑*

_{k}

*M*

_{jk}

*u*

_{k}. The goal is to perform such an operation using light fields. While this technique has already been introduced in classical optics,

^{27}here it will be reformulated for quantum computing, where the vector

*v*now encodes a normalized quantum state and

*M*encodes a unitary gate operator. First, notice that the matrix-vector product can be rewritten as

^{46}), denoted by the symbol ⊙, between our matrix

*M*and another matrix

*U*, which encodes or copies

*u*into its rows. The matrix

*U*can be obtained from the outer product,

*U*=

*u*

^{⊺}⊗

**1**, with

**1**= (1, 1, 1, 1, …)

^{⊺}.

We see that the matrix-vector multiplication can be decomposed into the elementwise product *M* ⊙ *U* and a subsequent summation of the columns. These operations can be achieved optically using spatial light modulators (SLMs) and a cylindrical lens (CL), as shown in Fig. 1(a), as demonstrated in Ref. 27. On one SLM, a uniform field can be modulated with a hologram that encodes (point-wise) the matrix *U* and is imaged onto a second SLM, which is encoded with the matrix *M*. The imaging system between the two SLMs enables the elementwise multiplication of the encoded matrices. The final operation is performed using a cylindrical lens that focuses the field in the direction that coincides with the columns of *M*, performing a column-wise summation—therefore completing the product to produce the elements *v*_{j}.

Remarkably, hidden in this approach is the fact that the transverse Cartesian coordinates are used as independent degrees of freedom that can be used to enact operations, analogous to non-interacting multi-particle systems in quantum computing. Next, we show how this idea can be used to emulate quantum computing with transverse fields.

### B. Formulation using quantum states

*ψ*(

*x*,

*y*) is described by the state |

*ψ*⟩ =

*∫ψ*(

*x*,

*y*)|

*x*⟩|

*y*⟩

*dxdy*where the basis states satisfy ⟨

*x*|

*x*′⟩ =

*δ*(

*x*−

*x*′) and ⟨

*y*|

*y*′⟩ =

*δ*(

*y*−

*y*′). This means that each photon in a laser field is defined on a Hilbert space $H\u221e\u2297H\u221e$ spanned by the Cartesian coordinate internal degrees of freedom (i.e., the coordinate states). By partitioning the transverse plane into

*N*bounded and non-overlap intervals, |

*x*⟩ → |

*x*

_{j}⟩ and |

*y*⟩ → |

*y*

_{k}⟩, shown in Fig. 1(b), we can now define qudit states that form a high dimensional qudit space on the combined Hilbert space, i.e., $HN\u2297HN$ that has dimensions

*N*

^{2}. This has been discussed in recent work,

^{47,48}showing that non-overlapping regions of transverse optical fields can be expressed using a basis formed from tensor product states, much like distinct particles that occupy their own Hilbert spaces. This ensures that the spatial modes corresponding to the

*x*and

*y*coordinates function as independent degrees of freedom. From these states, a uniform superposition can be prepared as

*U*that was defined earlier onto an operator that encodes information into the lattice as

^{49}Here, the coefficients mark the

*x*-components but copy all the elements,

*u*

_{m}, across the

*y*-components—this still leaves the

*y*-components independent of the

*x*-components. Similarly, for matrix

*M*, we have the operator,

*M*

_{nm}into each state |

*x*

_{m}⟩|

*y*

_{n}⟩ of the lattice. The combined operation $M\u0302U\u0302$ produces the state,

*v*

_{j}=

*∑*

_{k}

*M*

_{jk}

*u*

_{k}from before. While the result of the multiplication is encoded into the lattice, which is

*N*×

*N*in dimensions, the result can be read out as a column in the y-direction once the summation

*k*(in the x-component) is contracted. This can be done using the Fourier transforming (FT) lens in the x-direction—the analog of a quantum Fourier transform, therefore completing the circuit in Fig. 1(c). The result of this is an interference pattern, having a zero order component that corresponds to the amplitude, $\u2211jke\u2212ifxlxkMjkvk$ for the frequency component $fxl=0$. Measuring the zeroth order interference pattern in the x-direction integrates the x-component, therefore leaving the y-components in the state

*v*

_{j}=

*∑*

_{k}

*M*

_{jk}

*u*

_{k}, having the same outcome as

*v*=

*Mu*from Eq. (1). Because this scheme allows us to express operations of the x–y coordinates analogous to gate based computing platforms, we will exploit it for quantum computing, where the matrix mechanics that describe quantum computing can be formulated using the transverse spatial modes in Cartesian coordinates. Next, we introduce our basis of choice for doing this and illustrate the Hadamard gate.

## III. HADAMARD GATE

*x*

_{j},

*y*

_{k}) → |

*x*

_{j}⟩|

*y*

_{k}⟩ denote the centers of each Gaussian mode given by the states,

*x*

_{j},

*y*

_{k}) within a closed boundary of $Aj\xd7Ak\u2282R2$ that is non-overlapping. In this way, uniform superpositions such as in Eq. (2) can also be prepared, i.e., resulting in the field in the first panel of Fig. 1(d). The rest of the fields in the figure represent instances of the Hadamard basis states, which include the uniform superposition. Next, we show how the Hadamard gate can be enacted on these fields.

*N*= 2), we can describe the logical basis as |

*v*

_{0}⟩ ≡|0⟩ = (1,0)

^{⊺}and |

*v*

_{1}⟩ ≡|1⟩ = (0,1)

^{⊺}. In this basis, the Hadamard gate is given by $H\u03022=12111\u22121$. Applying the Hadamard gate maps the logical basis states onto the Hadamard basis states $|u1,2\u232a=1/2(|0\u232a\xb1|1\u232a)$, respectively. The states |

*u*

_{1,2}⟩ are orthogonal and form a basis. The Hadamard gate performs a change of basis; however, when applied twice, it leaves the state unchanged, i.e., $H\u0302H\u0302=I$, true for all dimensions N. For qudits,

*N*> 2, the Hadamard matrix can be computed for dimensions

*N*= 2

^{n}(

*n*power of 2) as $H\u0302N=H\u0302\u2297n$ using tensor products of

*n*Hadamard gates. Thus, the

*k*th Hadamard basis state can be obtained by applying the Hadamard gate to the

*k*th state in the logical basis following:

*m*⟩ are the standard basis states with coefficients (−1)

^{m·k}with

*m*·

*k*corresponding to the dot product of the binary representation of the integers

*m*and

*k*. Accordingly, the Hadamard basis states can be mapped onto our lattice states as

*N*= 4 dimensions. To encode these coefficients into the lattice, we use the operator $U\u0302$ in Eq. (3), but with the coefficients corresponding to our Hadamard basis states. Applying the Hadamard gate to each of the states in the lattice should map them back to the logical basis states, following $H\u0302N|uk\u232a=|vk\u232a$. Each basis state |

*u*

_{k}⟩ that is embedded in the lattice [as in Fig. 1(d)] can be mapped onto a unique element vector with one non-zero entry, as shown in Fig. 1(e). To encode the Hadamard gate, we can map its matrix components onto the lattice using Eq. (4), where

*M*

_{jk}will represent the matrix elements of the Hadamard gate. Thereafter, we apply the Fourier transform and zero order component filtering to complete the operator-state (matrix-vector) multiplication.

Next, we show how this scheme can be used to perform a well-known quantum algorithm.

### A. Application: Deutsch–Jozsa algorithm

The Deutsch–Jozsa algorithm^{50} provides an efficient quantum solution for determining whether a Boolean function, *f*(⋅), that takes binary values as inputs, is balanced (half of the inputs map to 1 and the other half to 0) or constant (all inputs either map to 0 or 1). To illustrate this, consider a collection of 2-bit input strings chosen from the set $B={00,01,10,11}$; each element $k\u2208B$ can be used as an input to the function, i.e., *F*(*k*). A balanced function would return 0 for half the entries, e.g., *k* ∈ {00, 11}, and 1 for the other half, *k* ∈ {01, 10}, as shown in the first left panel of Fig. 2(a). The second example [top right panel of Fig. 2(a)] shows an alternative combination that can also represent a balanced function. For the constant case, all binary values map to a single output, i.e., {00, 01, 10, 11} → 0 or {00, 01, 10, 11} → 1 as shown in the bottom panel of Fig. 2(b) for two instances of such a function.

To query the nature of such a function, the quantum computer prepares a superposition of all possible binary values in $B$, queries the function values simultaneously, and through interference it returns a result indicating whether the function is balanced or not. We adapt the algorithm to our encoding scheme using the lattice basis and our operator-state (matrix-vector) multiplication scheme.

*F*(·) in the set $B$ to the logical basis states,

*v*

_{k}⟩ from the previous section. In the algorithm, we will see that the mappings of the gates convert between the Hadamard basis states (|

*u*

_{k}⟩) and the logical basis states (|

*v*

_{k}⟩). To prepare the uniform superposition (|0⟩ + |1⟩ + |2⟩ + |3⟩) using our lattice, we can use the first element of the Hadamard basis following Eq. (9),

*F*(

*k*) is encoded onto the unitary operator as

*U*

_{F}so that the states in the superposition become

*∑*

_{k}(−1)

^{F(k)}|

*k*⟩, showing that

*U*

_{F}is diagonal and has the form

^{F(k)}. As such, we see that

*U*

_{F}encodes a

*π*phase depending on whether

*F*(

*k*) is 0 or 1. Motivated by this, we encode the unitary as $U\u0302F=\u2211k(UF)kk|xk\u232a\u2329xk|\u2297I$ onto our lattice, where $(UF)kk$ are the diagonal elements of

*U*

_{F}, marking the x-components of the lattice with the desired phases. In this way, we do not need ancillary particles thanks to the higher dimensional nature of our degrees of freedom.

*v*

_{0}⟩ ≡ |

*y*

_{0}⟩. In the N = 4 binary example, this is similar to obtaining the |

*v*

_{0}⟩ ≡ |00⟩ state. The balanced case returns an arbitrary superposition of the logical basis states with coefficients given by $uj=1N\u2211m(\u22121)m\u22c5j+F(j)$, where

*m*·

*j*is the binary inner product using the binary representation of

*m*and

*j*. For example, a balanced function that maps as {00, 11} → 1 and {01, 10} → 0, corresponds to a unitary,

*v*

_{3}⟩ ≡ − |11⟩. In general, the output state is one of the logical basis states that exclude |

*v*

_{0}⟩ ≡ |00⟩ as shown in Fig. 2(b). In our setup, we execute the protocol by encoding |

*u*

_{0}⟩ on the first SLM and then subsequently encode $M\u0302=H\u0302NU\u0302$ onto the second SLM.

## IV. EXPERIMENT

In Fig. 3, we illustrate the setup used for our demonstration. To ensure a uniform field intensity across the transverse plane, we overfilled the first spatial light modulator (SLM_{1}) by magnifying a laser beam from a Helium Neon (HeNe) source with a wavelength of 633 nm using the telescope. On SLM_{1}, the input vector for the lattice of Gaussian modes was encoded as an array of displaced Gaussian beams, producing the superposition state, |Ψ⟩ ≡ |*u*_{0}⟩ from Eq. (2). To alter the coefficients of the lattice, each row of the matrix (U) mapping the vector was encoded using a digital hologram that encodes amplitudes and phases^{51} onto each of the Gaussian modes. Because the SLM encodes the vector state as a matrix, *U*, given any state |*u*⟩, the elements were copied into its rows following the procedure outlined in the theory.

The matrix generated on SLM_{1} was then transferred to SLM_{2} using an imaging system consisting of lenses *L*_{1} and *L*_{2}. An aperture (AP) was placed between the two lenses to filter the modulated first order diffraction pattern from SLM_{1}. On SLM_{2}, we applied an additional phase encoding to the lattice/matrix elements, thereby completing the optical representation of the matrix-vector multiplication process. Following the encoding on SLM_{2}, the beam was passed through a cylindrical lens (CL) to undergo a one-dimensional Fourier transform. This operation focused the outcome of the matrix-vector multiplication into the central fringe (shown as an inset in Fig. 3), specifically at the zeroth order Fourier component in coordinate space. To extract this outcome accurately, we employed digital filtering, enabling precise capture of the resultant vector as shown in the inset of Fig. 3.

## V. RESULTS

### A. Matrix-multiplication

To characterize our system, we exploit the orthogonality of the Hadamard basis. In order to do this, we prepared the Hadamard basis states |*u*_{j}⟩ on SLM_{1} and encoded the Hadamard transform on SLM_{2}. Thereafter, we propagated the field through the cylindrical lens and collected the resulting interference pattern on a CCD camera. The multiplication between the Hadamard basis states and the Hadamard gate enables us to clearly distinguish between different columns of the output vector state. Accordingly, we obtain orthogonal states (|*v*_{j}⟩) with distinct positions marked by bright lobes. We show a measured example of this for *N* = 2 dimensions in Fig. 4(a), where the first basis state, |*u*_{0}⟩, is encoded on the lattice and measured using the Hadamard gate. The outcome is a measured interference pattern, where the resulting filtered zero order produces a bright lobe in the first entry—for this specific example, the result corresponds to the state |*v*_{0}⟩. Summing and normalizing the intensity for each region of the output vector corresponded to extracting the output vector elements.

We repeated the process for all the basis states for a given dimension. In Fig. 4(b), we show the measured lobes for all the states in *N* = 2, confirming that the Hadamard basis states (|*u*_{0}⟩ and |*u*_{1}⟩) are mapped on to the basis states |*v*_{0}⟩ and |*v*_{1}⟩. From the measured lobes, we extracted the intensity from each component and produced a crosstalk matrix (CM). For *N* = 2, the crosstalk matrix resembles an identity matrix, showing that the measured basis modes are distinguishable and, therefore, confirms orthogonality between the measured vectors. To quantify this, we measured a fidelity of F = 0.99 ± 0.01, showing that the Hadamard matrix can map the basis elements |*u*_{j}⟩ onto the basis states |*v*_{j}⟩. This was calculated by normalizing each row and computing the average over the diagonal components.

Figures 4(c)–4(e) show the extension of this process to higher-dimensional matrices. For dimensions *N* = 4, *N* = 8, and *N* = 16, we obtain average fidelities of 0.96 ± 0.01, 0.94 ± 0.05, and 0.81 ± 0.02 multiplication, respectively. However, as the dimensions increase, we note that the fidelity decreases. We attribute this to the diffraction of Gaussian beams. Increasing the dimension or number of Gaussian modes for the same physical size of the matrix means decreasing the beam waist *w*_{0} of each mode. As the beam waists get smaller, they expand at a faster rate during propagation, according to $w(z)=w01+\lambda z\pi w022$. Given that the cylindrical lens focuses light in one direction while neglecting the other, we expect the unfocused direction to continue expanding more rapidly as *w*_{0} gets smaller, resulting in overlapping vector elements that are hard to distinguish. This diffraction effect impacts the fidelity of higher-dimensional computations.

### B. Deutsch–Jozsa algorithm demonstration

Using our scheme, we demonstrate the Deutsch–Jozsa algorithm for a function that encodes information using *N* = 2, *N* = 4, and *N* = 8 basis elements, shown in Figs. 5(a)–5(c), respectively. We initialized our system in the superposition state |*u*_{0}⟩ by digitally displaying a hologram encoding the uniform lattice of Gaussian modes on SLM_{1}. The action of the oracle phase transformation and the subsequent Hadamard gate are encoded as a compound unitary transformation $HU\u0302F$ on the second (SLM_{2}). The light beam is then sent through a cylindrical lens, which acts as a summing operator. The resulting interference pattern that was measured with the CCD camera and filtered zero order vector components are shown as insets in each figure.

From these images, we then plot the cross section of the normalized intensity against the vector element number. In this case, we can distinguish whether the function is balanced or constant by interrogating the presence or absence of light in the spatial position of the vector element. Using our basis vectors from the characterization, this means a constant function produces the vector |*v*_{0}⟩ and if the function is balanced |*v*_{j≠0}⟩. The instance of the oracle operator $(U\u0302F)$ used for each type of function is shown in each figure; this is shown as an inset in the intensity plots representing the measured components.

For each case, we accurately determined whether the function encoded in the unitary operation is constant or balanced. The average fidelity of these measurements exceeded 90% across all cases. In particular, for N = 2, 4, and 8, we achieved fidelities of 0.99 ± 0.01, 0.97 ± 0.01, and 0.93 ± 0.05, respectively.

## VI. DISCUSSION AND CONCLUSION

In this study, we utilized optical matrix-vector multiplication to emulate quantum computing by treating the *x*–*y* components of a coherent field as a tensor product space, $HN\u2297HN$, derived from individual coordinates. The encoding basis was defined within this Hilbert space using a lattice of Gaussian modes, where the positions of the centers in the *x*–*y* coordinates established localized states. Vector states were encoded along the *x*-coordinate, while both coordinates were employed to encode the matrix operator. The output vector was measured along the *y*-coordinate after filtering out the zero-order component of the output interference pattern. We demonstrated the use of Hadamard basis elements and the Hadamard gate, achieving encoding and decoding fidelities as high as 95% for *N* = 8 dimensions and above 80% for *N* = 16.

Furthermore, our implementation of the Deutsch–Jozsa algorithm using optical vector matrix multipliers leverages the representation of quantum states as vectors and quantum operators as matrices that can be imprinted on our lattice basis. Optically, we prepare multiple identical Gaussian modes in parallel, with each mode representing an element of the states that are input to the function *F*(*k*). The high-dimensional nature of our encoding scheme enables the oracle function in our demonstration to be encoded as a diagonal operator.

However, we note spatial resources required to perform computations using structured light in higher dimensions are fundamentally limited by the diffraction limit. The minimum separation between distinguishable spatial modes is constrained by the wavelength of light and the numerical aperture of the optical system, leading to crosstalk between modes when attempting to scale up to higher dimensions. In our current setup, we have explored up to 16 distinguishable spatial modes, equivalent to a 4-qubit system. Spall’s vector-matrix demonstration reached up to ≈50 dimensions of encoding—in principle, every pixel of the SLM can be utilized as an encoding channel but would require much effort. Moreover, as the number of spatial modes increases, the complexity of addressing and manipulating these modes grows significantly. In quantum systems, the number of operations required for a computation scales polynomially with the number of qubits, whereas in classical systems, the need to individually resolve and address each spatial mode results in a linear scaling with the number of available modes. This ultimately limits the scalability of classical systems in performing quantum-like operations.

In addition, the preparation of Gaussian lattices and their unitary transformation matrices on an SLM typically involves NxN operations to generate the necessary hologram for the spot array, which can be computationally expensive and inefficient when scaling to higher dimensions. An alternative approach is the use of fan-out operations to generate the lattice of Gaussian modes.^{52,53} Techniques such as cylindrical lenses^{54} or diffractive optical elements^{55} can directly produce the desired lattice by splitting or reshaping the input beam, reducing the need for pixel-by-pixel modulation on the SLM and significantly improving efficiency. Recent advances in trained diffractive optical elements provide another potential solution by allowing computationally designed optical masks to perform the necessary optical transformations.^{35} This approach leverages inverse design techniques to optimize optical circuits, embedding high-dimensional transformations in complex media without requiring precise control over individual elements. Such masks streamline the process by reducing the need for real-time computation and re-calibration, ensuring scalability, and maintaining the accuracy of the transformations.

We acknowledge the proposal by Perez-Garcia *et al.*,^{40} which employs classical light following Dragoman’s method. However, this approach necessitates multiple optical elements to prepare the superposition state. In contrast, our method efficiently prepares the state in a single step by projecting light onto a spatial light modulator (SLM) in a reprogrammable manner—the digital encoding allows for dynamic control and can, therefore, be adapted for any operation. Therefore, we anticipate that any transformation (operator/gate) can be encoded, including X-gate, Z-gate, etc., because the method allows any matrix operation to be encoded into the lattice.

## ACKNOWLEDGMENTS

The authors acknowledge Professor Andrew Forbes for his fruitful discussions and valuable advice. The authors also acknowledge the South African Quantum Initiative (SAQuti), the National Research Foundation (South Africa), and Optica for funding.

## AUTHOR DECLARATIONS

### Conflict of Interest

The authors have no conflicts to disclose.

### Author Contributions

**Mwezi Koni**: Conceptualization (equal); Formal analysis (equal); Investigation (equal); Writing – original draft (equal). **Hadrian Bezuidenhout**: Investigation (supporting); Methodology (supporting); Writing – review & editing (supporting). **Isaac Nape**: Conceptualization (equal); Formal analysis (equal); Supervision (equal); Writing – original draft (equal); Writing – review & editing (equal).

## DATA AVAILABILITY

The data that support the findings of this study are available from the corresponding author upon reasonable request.

## REFERENCES

*Classical and Quantum Computation*