Native QR Factorization on Programmable Photonic Meshes S.A. Fldzhyan, S.S. Straupe, M.Yu. Saygin Abstract We propose a photonic native procedure for computing the QR factorization of a matrix using a programmable unitary interferometer mesh. The method configures the mesh through a sequence of local power routing steps within tunable two mode interferometric elements, while reading out the resulting upper triangular factor directly from the optical outputs. The number of physical operations grows quadratically ( O ⁡ ( N 2 ) O(N^{2}) ) with matrix size, matching the information content of a dense input and reducing runtime relative to standard digital QR routines, which scale cubically ( O ⁡ ( N 3 ) O(N^{3}) ). Beyond single factorizations, the same architecture supports iterative spectral computations by reusing the configured interferometer in a mirrored arrangement that implements the core update step of the QR eigenvalue algorithm. We also describe related optical procedures for Hessenberg reduction and Bidiagonalization, serving as compatible preprocessors for QR and SVD workflows. Finally, we analyze the impact of finite control resolution on the computed factors. I Introduction Programmable integrated photonics has matured into a practical hardware platform for realizing large, reconfigurable linear transformations on optical fields 4 ; 42 . This progress spans novel mesh architectures and designs 11 ; 26 ; 15 , robust calibration and programming strategies 21 ; 22 ; 23 ; 43 , and fundamental studies of algorithmic complexity and physical limits 29 ; 35 ; 19 ; 36 ; 25 . These advances have enabled hardware demonstrations of core linear algebra operations performed directly in the optical domain 37 ; 38 ; 27 ; 30 ; 7 ; 8 ; 5 ; 6 . Together, they motivate a complementary perspective: rather than using optical meshes solely as analog accelerators for repeated matrix-vector multiplications, we can harness them to physically execute structured linear algebra routines whose conventional digital implementations are bottlenecked by sequential arithmetic. A canonical example is the QR factorization. For a matrix A\in\mathbb{C}^{N\times N} , QR produces a unitary Q and an upper triangular R such that A=QR . QR is central to least squares solvers, orthogonalization, and iterative spectral methods such as the QR algorithm 40 ; 16 ; 1 . In standard numerical linear algebra, dense QR requires O(N^{3}) digital floating-point operations, implemented via Householder reflections or Givens rotations. This arithmetic cost, however, is not necessarily aligned with the physical capabilities of a programmable interferometer: once a unitary transformation is configured, optical propagation applies it at essentially constant latency, and the dominant overhead shifts to device configuration and readout. Complex field amplitudes can be measured, for example, using coherent I/Q receivers 20 , and intensity-only approaches can reconstruct transfer matrices in many settings 3 ; 2 . In what follows, we assume that reading the complex field in one port is an O(1) operation. In this work we propose an analog QR procedure tailored to universal unitary meshes. The key primitive is a tunable 2\times 2 interferometric block whose phase parameters can be adjusted to concentrate optical power from two inputs into a single output, thereby implementing a complex Givens rotation. By composing such local power concentration operations within a triangular Reck mesh 33 , the device configures a left unitary transformation U satisfying UA=R , where R is upper triangular and can be directly measured, column by column, from the optical outputs. The standard QR factorization then follows as A=QR with Q:=U^{\dagger} . Importantly, the unitary factor is stored in the settings of the mesh. When needed, it can be queried optically using reciprocity and inverting calibrated phases 31 . Beyond a single factorization, we show that the same hardware can implement the factor swap update of the iterative QR eigenvalue algorithm using mirrored inverse modules (Section III ). We also provide compatible optical procedures for Hessenberg reduction and Bidiagonalization (Sections IV and V ), which are standard preprocessors for efficient QR- and SVD-based spectral computations. Finally, Section VI analyzes finite precision control. II Optical QR decomposition This section presents the core primitive: physically triangularizing a target matrix A by configuring a programmable unitary interferometer. The objective is to realize a unitary left action such that UA=R is upper triangular while directly measuring R during configuration. II.1 Physical operation When analyzing the asymptotic complexity of our protocols, we adopt the notion of a physical operation , defined as any of the following: (i) encoding an input vector via a physical preparation scheme and injecting it into N ports, (ii) reading out N complex outputs, and (iii) reconfiguring tunable elements of the photonic mesh. Our QR procedure requires O(N^{2}) such operations ( N column injections and measurements with O(N) elements reconfigurations each) matching the O(N^{2}) degrees of freedom of a dense matrix and not exceeding the loading cost for X-bar processors 9 ; 44 ; 14 . Light propagation time is negligible in real setting, pedantically, with O(N) propagation time (due to device depth) per vector over N vectors, the total contribution remains O(N^{2}) and thus consistent with the overall complexity. II.2 Tunable 2\times 2 block and power concentration The procedure relies on a tunable 2\times 2 unitary block T , presented in Fig. 1 (a), that independently controls a splitting ratio and a relative phase. Such blocks can physically be realized, e.g., using a phase shifter combined with a tunable beam splitter, a standard Mach-Zehnder interferometer (MZI), 3-MZI, or an MZI with a crossing 33 ; 10 ; 18 . The sole requirement is power concentration capability: given an arbitrary input vector (x_{1},x_{2})^{T} , one can tune the phase \phi=\arg(-x_{2}/x_{1}) and splitting ratio \tan(\theta/2)=|x_{2}/x_{1}| to obtain \begin{pmatrix}e^{i\phi}\cos{\frac{\theta}{2}}&-\sin{\frac{\theta}{2}}\\ e^{i\phi}\sin{\frac{\theta}{2}}&\cos{\frac{\theta}{2}}\end{pmatrix}\!\!\begin{pmatrix}x_{1}\\ x_{2}\end{pmatrix}=\begin{pmatrix}-e^{i\arg{x_{2}}}\sqrt{|x_{1}|^{2}+|x_{2}|^{2}}\\ 0\end{pmatrix}. (1) Equation ( 1 ) is the optical analogue of a complex Givens rotation: one component is nulled while preserving total power (up to a phase). II.3 Reck mesh and Givens arrays We adopt the triangular Reck decomposition mesh as the universal unitary backbone (Fig. 1 (b)). Following 34 , we group interferometric blocks into Givens rotation arrays Y_{s} (Fig. 1 (c)), yielding the compact representation shown in Fig. 1 (d). By sequentially applying the power concentration property within the constituent T blocks, the total optical power of any input incident on Y_{s} can always be routed into the uppermost channel. A notable feature of this scheme is its capacity for self-configuration 28 : the system can align itself using only local feedback loops that maximize power at designated nodes, potentially eliminating the need for external digital processing. Figure 1: Optical architecture. (a) Fundamental tunable 2\times 2 interferometric block T . (b) N=6 Reck unitary mesh. (c) Structure of Givens array Y_{s} . (d) Compact representation using Givens arrays. II.4 Optical QR decomposition protocol Let A=[\vec{a}_{1},\ldots,\vec{a}_{N}] be the target matrix provided as a sequence of input columns. The optical QR procedure configures the mesh so that after processing \vec{a}_{i} the output has zeros below row i , and the resulting output column becomes the i -th column of R . Fig. 2 illustrates the step by step procedure for N=6 . The optical QR decomposition proceeds as follows: 1. Initialization: Initialize all Givens arrays to the identity transformation, i.e., set Y^{(0)}_{s}=I . Set the column index to i=1 . 2. Injection and readout: Inject the column vector \vec{a}_{i} and measure the output vector \vec{b}_{i} across all ports. 3. Configure the next array: Using the measured subdiagonal components of \vec{b}_{i} , configure the Givens array Y_{N+1-i} to concentrate optical power into the first i output ports. This requires O(N-i) local parameter updates. 4. Iterate: Increment i and repeat steps 2 & 3 until i=N . 5. Final column: Inject \vec{a}_{N} to read out the last column of R . Figure 2: Step by step physical QR decomposition for N=6 . Columns of A are injected sequentially while Givens arrays Y_{N} through Y_{2} zero subdiagonal elements. Red symbols mark the newly configured array Y_{N+1-i} at step (i) . The final injection yields the last column of R . At the conclusion of the process, the programmed unitary U satisfies UA=R, (2) where R is upper triangular and is obtained from the measured output columns. The number of physical operations is O(N^{2}) : there are N column injections and O(N) local configuration steps per column. For the N=6 example in Fig. 2 , the resulting R has the schematic form R=\begin{pmatrix}e^{i\xi_{1}}\sqrt{\sum\limits_{i=1}^{6}|b^{i}_{1}|^{2}}&b^{1}_{2}&\cdots&b^{1}_{5}&b^{1}_{6}\vskip-4.91673pt\\ 0&e^{i\xi_{2}}\sqrt{\sum\limits_{i=2}^{6}|b^{i}_{2}|^{2}}&\cdots&b^{2}_{5}&b^{2}_{6}\\ 0&0&\cdots&b^{3}_{5}&b^{3}_{6}\vskip 4.91673pt\\ 0&0&\cdots&b^{4}_{5}&b^{4}_{6}\\ 0&0&\cdots&e^{i\xi_{5}}\sqrt{\sum\limits_{i=5}^{6}|b^{i}_{5}|^{2}}&b^{5}_{6}\\ 0&0&\cdots&0&b^{6}_{6}\\ \end{pmatrix}, (3) where \xi_{i} are residual phases resulting from the concentration steps. II.5 Recovering Q Defining Q:=U^{\dagger} yields the standard QR factorization A=QR. (4) The entries of Q are not explicitly computed during the procedure, instead, Q is stored in the mesh settings. If an application requires explicit access to Q (or the ability to apply Q to vectors), there are two natural options. First, one may characterize the configured unitary U by injecting basis vectors and measuring outputs, which costs O(N^{2}) . Second, one may exploit optical reciprocity 31 : by reversing the propagation direction and inverting the calibrated phases in the 2\times 2 blocks, the hardware can implement transposition and conjugation relations needed to realize U^{\dagger} optically. In many routines, including QR-based eigenvalue iterations, it suffices to apply Q and Q^{\dagger} physically rather than to list their entries. II.6 Input preparation The column injection stage does not require a full universal encoding of A (X-bar 9 ; 44 ; 14 , SVD 28 or embedding 39 ; 13 ) configured for all N^{2} entries. Instead, a dedicated vector synthesis circuit can generate an arbitrary complex column \vec{a}_{i} , e.g., Y_{N} by launching light into last port and choosing successive T settings to match desired amplitudes and phases. The required parameters can be computed in O(N) time per column, preserving the overall O(N^{2}) physical operations scaling. III Optical implementation of the QR eigenvalue iteration Having an O(N^{2}) optical method to obtain UA=R , one can reuse it repeatedly to compute spectral information rather than a single factorization. The QR algorithm generates a sequence \{A_{k}\} by factoring each iterate and swapping the factors, A_{k}=Q_{k}R_{k},\qquad A_{k+1}=R_{k}Q_{k}=Q_{k}^{\dagger}A_{k}Q_{k}, (5) so the iteration preserves eigenvalues while driving the matrix toward Schur form 40 ; 16 ; 1 . With shifts, convergence is accelerated in practice, and for normal matrices the limit is diagonal with eigenvectors obtained from the accumulated Q_{k} factors. Here we explain how the same photonic hardware can implement that swap natively via mirrored modules, turning each iteration into a reprogram and measure loop. III.1 Mirrored modules and factor swapping in hardware The optical QR procedure yields a left factorization U_{k}A_{k}=R_{k} with unitary U_{k} , so Q_{k}=U_{k}^{\dagger} . To implement the update A_{k+1}=R_{k}Q_{k} optically, we use two mirrored Reck-based programmable units, Q^{(R)} and Q^{(L)} , flanking a central X-bar array (Fig. 3 (a)) — the latter necessary to preserve O(N^{2}) iteration complexity. When programming mirrored units with opposite phase and same splitting settings, they realize inverse transformations Q^{(L)}(\bm{\theta},-\bm{\phi})\,Q^{(R)}(\bm{\theta},\bm{\phi})=I . Structurally, Q^{(L)} employs Givens arrays X_{s} that reverse the operation order of the Y_{s} arrays in Q^{(R)} (Fig. 3 (b)), enabling a native factor swap: after measuring R_{k} , it is reencoded in the central stage and multiplied by U_{k}^{\dagger} via the mirrored module to produce the next iterate. Figure 3: Optical iterative QR algorithm for N=6 . (a) Two universal Reck interferometers with mirrored inverse Givens arrays ( Q^{(L)} , Q^{(R)} ). (b) Array X_{s} , the structural inverse of Y_{s} . (c) First three iterations, red symbols mark parameters determined at step (i) . III.2 QR eigenvalue iteration protocol The iterative optical QR algorithm proceeds as follows: 1. Initialization: Set Q^{(L)} and Q^{(R)} to identity, load A_{1}=A into the central X-bar array, and set i=1 . 2. QR step: Inject columns j=1,\dots,N to execute the optical QR decomposition (Sec. II ), yielding parameters \bm{\theta_{i}} and \bm{\phi_{i}} that configure Q^{(R)}(\bm{\theta}_{i},\bm{\phi}_{i}) and the measured upper triangular R_{i} , such that Q^{(R)}(\bm{\theta}_{i},\bm{\phi}_{i})A_{i}=R_{i} . 3. Factor swap: Form A_{i+1}=R_{i}Q^{(R)\dagger}(\bm{\theta}_{i},\bm{\phi}_{i}) by loading R_{i} into the X-bar array and programming Q^{(L)} with inverted phases -\bm{\phi}_{i} . Because Q^{(L)}(\bm{\theta}_{i},-\bm{\phi}_{i})=Q^{(R)\dagger}(\bm{\theta}_{i},\bm{\phi}_{i}) , this implements the factor swap in hardware. 4. Iterate: Increment i and repeat steps 2 & 3 until A_{i} converges to Schur (or diagonal for normal matrices) form. The data flow for the first three iterations is conceptually mapped out in Fig. 3 (c). Since the QR factorization is performed column by column, some hardware simplifications are possible. For example, replacing the full left module with a single array X_{N} can reduce optical depth. In that case, one must ensure that at each internal step the incident distribution matches the required column of Q^{(R)\dagger} . If Q^{(R)} has been characterized, the needed physical parameters can be set in O(N) time per column. The proposed scheme can be readily modified to implement the shifted QR algorithm, a standard technique for accelerating convergence 1 . This extension is straightforward because applying a shift manifests as a simple correction to a single component of the output vector for each injected column input. For a target matrix A preprocessed to Hessenberg form (see next section), the implicit Q theorem guarantees that a single pair of Givens arrays Q^{(R)}=X_{N} , Q^{(L)}=Y_{N} is sufficient to perform QR iterations with shifts using the “chasing the bulge” technique 16 (Theorem 7.4.2 and Paragraph 8.3.5). This greatly simplifies the optical scheme, although it provides no asymptotic speedup relative to digital implementations in this case. IV Optical Hessenberg reduction In standard dense matrix eigensolvers, QR iterations are rarely applied to A directly. Instead, A is reduced to upper Hessenberg form via a unitary similarity transform, a preprocessing step that costs O(N^{3}) arithmetic operations in digital implementations 16 . One constructs a unitary U such that UAU^{\dagger}=H, (6) where H is upper Hessenberg: all entries below the first subdiagonal are zero, i.e., h^{i}_{j}=0 for i>j+1 . The key benefit is that QR iterations on a Hessenberg matrix can be performed in O(N^{2}) digital steps using bulge chasing, rather than O(N^{3}) 40 ; 16 . The optical setup in Fig. 4 implements Hessenberg reduction in O(N^{2}) physical operations. Compared to the full QR eigenvalue iteration setup, the unitary modules can be shortened because full universality is not required: only the arrays involved in eliminating entries below the first subdiagonal need to be configured. The optical Hessenberg reduction protocol proceeds as follows: 1. Initialization: Set shortened unitary modules Q^{(L)} , Q^{(R)} to identity, load A into the central unit, and set i=1 . 2. Concentration: Inject light into port i , configure Y_{N-i} in Q^{(R)} to concentrate power into the first i+1 outputs. The measured output gives column i of H . 3. Update: Program X_{N-i}=Y_{N-i}^{\dagger} in Q^{(L)} using the same splittings and inverted phases. 4. Iteration: Increment i , repeat steps 2 & 3 until i=N-1 . 5. Final colums: Inject ports N-1 and N to obtain the last two columns of H . Figure 4: Optical Hessenberg decomposition for N=6 . (a) Two shortened (nonuniversal) Reck interferometers with mirrored inverse Givens arrays ( Q^{(L)} , Q^{(R)} ). (b) Decomposition workflow: red symbols mark the Givens arrays updated at step (i) . This optical Hessenberg reducer can serve as a preprocessor: it produces a structured matrix suitable for subsequent optical or numerical QR iterations, with the advantage that the preprocessing avoids O(N^{3}) cost. V Optical Bidiagonalization While Hessenberg reduction prepares a matrix for QR algorithm, many applications instead require singular values and singular vectors, where the standard entry point is bidiagonalization 40 ; 16 . For any matrix A , one can find unitary matrices U and V in O(N^{3}) digital steps such that UAV=B=\begin{pmatrix}d_{1}&f_{1}&0&&\cdots&0\\ 0&d_{2}&f_{2}&&&\mathchoice{\vbox{\kern 3.26465pt\vbox to7.48764pt{\hbox{$\displaystyle.$}\vfill\hbox{$\displaystyle.$}\vfill\hbox{$\displaystyle.$}}}}{\vbox{\kern 3.26465pt\vbox to7.48764pt{\hbox{$\textstyle.$}\vfill\hbox{$\textstyle.$}\vfill\hbox{$\textstyle.$}}}}{\vbox{\kern 2.17635pt\vbox to5.06042pt{\hbox{$\scriptstyle.$}\vfill\hbox{$\scriptstyle.$}\vfill\hbox{$\scriptstyle.$}}}}{\vbox{\kern 1.81467pt\vbox to4.13484pt{\hbox{$\scriptscriptstyle.$}\vfill\hbox{$\scriptscriptstyle.$}\vfill\hbox{$\scriptscriptstyle.$}}}}\\ &&\mathinner{\mathchoice{\vbox{\kern 3.26465pt\vbox to7.48764pt{\hbox{$\displaystyle\mathpunct{.}$}\vfill\hbox{$\displaystyle\mathpunct{\kern 2.2639pt}\mathpunct{.}$}\vfill\hbox{$\displaystyle\mathpunct{\kern 2.2639pt}\mathpunct{\kern 2.2639pt}\mathpunct{.}$}}}}{\vbox{\kern 3.26465pt\vbox to7.48764pt{\hbox{$\textstyle\mathpunct{.}$}\vfill\hbox{$\textstyle\mathpunct{\kern 2.2639pt}\mathpunct{.}$}\vfill\hbox{$\textstyle\mathpunct{\kern 2.2639pt}\mathpunct{\kern 2.2639pt}\mathpunct{.}$}}}}{\vbox{\kern 2.17635pt\vbox to5.06042pt{\hbox{$\scriptstyle\mathpunct{.}$}\vfill\hbox{$\scriptstyle\mathpunct{\kern 1.36111pt}\mathpunct{.}$}\vfill\hbox{$\scriptstyle\mathpunct{\kern 1.36111pt}\mathpunct{\kern 1.36111pt}\mathpunct{.}$}}}}{\vbox{\kern 1.81467pt\vbox to4.13484pt{\hbox{$\scriptscriptstyle\mathpunct{.}$}\vfill\hbox{$\scriptscriptstyle\mathpunct{\kern 0.97221pt}\mathpunct{.}$}\vfill\hbox{$\scriptscriptstyle\mathpunct{\kern 0.97221pt}\mathpunct{\kern 0.97221pt}\mathpunct{.}$}}}}\mkern 3.0mu}&\mathinner{\mathchoice{\vbox{\kern 3.26465pt\vbox to7.48764pt{\hbox{$\displaystyle\mathpunct{.}$}\vfill\hbox{$\displaystyle\mathpunct{\kern 2.2639pt}\mathpunct{.}$}\vfill\hbox{$\displaystyle\mathpunct{\kern 2.2639pt}\mathpunct{\kern 2.2639pt}\mathpunct{.}$}}}}{\vbox{\kern 3.26465pt\vbox to7.48764pt{\hbox{$\textstyle\mathpunct{.}$}\vfill\hbox{$\textstyle\mathpunct{\kern 2.2639pt}\mathpunct{.}$}\vfill\hbox{$\textstyle\mathpunct{\kern 2.2639pt}\mathpunct{\kern 2.2639pt}\mathpunct{.}$}}}}{\vbox{\kern 2.17635pt\vbox to5.06042pt{\hbox{$\scriptstyle\mathpunct{.}$}\vfill\hbox{$\scriptstyle\mathpunct{\kern 1.36111pt}\mathpunct{.}$}\vfill\hbox{$\scriptstyle\mathpunct{\kern 1.36111pt}\mathpunct{\kern 1.36111pt}\mathpunct{.}$}}}}{\vbox{\kern 1.81467pt\vbox to4.13484pt{\hbox{$\scriptscriptstyle\mathpunct{.}$}\vfill\hbox{$\scriptscriptstyle\mathpunct{\kern 0.97221pt}\mathpunct{.}$}\vfill\hbox{$\scriptscriptstyle\mathpunct{\kern 0.97221pt}\mathpunct{\kern 0.97221pt}\mathpunct{.}$}}}}\mkern 3.0mu}&&\\ &&&d_{N-2}&f_{N-2}&0\\ \mathchoice{\vbox{\kern 3.26465pt\vbox to7.48764pt{\hbox{$\displaystyle.$}\vfill\hbox{$\displaystyle.$}\vfill\hbox{$\displaystyle.$}}}}{\vbox{\kern 3.26465pt\vbox to7.48764pt{\hbox{$\textstyle.$}\vfill\hbox{$\textstyle.$}\vfill\hbox{$\textstyle.$}}}}{\vbox{\kern 2.17635pt\vbox to5.06042pt{\hbox{$\scriptstyle.$}\vfill\hbox{$\scriptstyle.$}\vfill\hbox{$\scriptstyle.$}}}}{\vbox{\kern 1.81467pt\vbox to4.13484pt{\hbox{$\scriptscriptstyle.$}\vfill\hbox{$\scriptscriptstyle.$}\vfill\hbox{$\scriptscriptstyle.$}}}}&&&0&d_{N-1}&f_{N-1}\\ 0&\cdots&&&0&d_{N}\end{pmatrix}, (7) where B is called (upper) bidiagonal, and d_{i} , f_{i} can always be chosen real. Subsequent SVD computations are then simplified because B^{T}B is symmetric tridiagonal. The optical setup in Fig. 5 performs bidiagonalization in O(N^{2}) physical operations by alternating left to right and right to left concentration steps. Optical reciprocity is used by injecting light from the opposite side to reverse the effective order of operations 31 . The optical Bidiagonalization protocol proceeds as follows: 1. Initialization: Set Q^{(L)} and Q^{(R)} to identity, load A into the central unit, and set i=1 . 2. Left to right concentration: Inject port i on the left, configure Y_{N+1-i} in Q^{(R)} to concentrate power into the first i right outputs. The measured output gives column i of B . 3. Right to left concentration: Inject port i on the right, configure X_{N-i} in Q^{(L)} to concentrate power into the first i+1 left outputs. The measured output gives row i of B . 4. Iteration: Increment i , repeat steps 2 & 3 until i=N-1 , then perform one final left to right concentration at i=N-1 . 5. Final entries: Inject left port N to obtain the last column of B . Figure 5: Optical bidiagonalization for N=6 . (a) Setup with one shortened (nonuniversal) and one universal Reck multiport interferometer: Q^{(L)} and Q^{(R)} use mirrored inverse Givens arrays. (b) Decomposition workflow: red symbols mark the Givens arrays updated at step (i) . VI Hardware Awareness The algorithms above assume an ideal programmable unitary acting on complex amplitudes, but real devices face loss, finite control precision, and physical layout limits. Here we translate algorithmic steps into hardware requirements by analyzing phase quantization effects. VI.1 Bit Precision We assess how finite phase precision impacts optical QR decomposition, assuming perfect measurements but quantized phase settings in the T blocks. In a standard MZI, phase and splitting parameters \phi and \theta are set in steps of 2\pi/2^{b} and \pi/2^{b} , respectively, where b is the number of bits. Notice that simple rounding of ideal parameters from ( 1 ) is not always optimal. Column preparation is also subject to finite precision. Figure 6 illustrates one possible column preparation strategy: input x is chosen so the largest amplitude matrix coefficient is encoded exactly (at \theta=\pi ), with \phi_{i} and \theta_{i} as the tunable parameters. Decomposition quality is evaluated by comparing the optical result ( Q^{\prime},R^{\prime} ) to a high precision numerical QR ( Q,R ) from SciPy 41 , using target matrices taken from the Ginibre ensemble normalized by the largest element modulus. To account for nonuniqueness of QR decomposition, we apply a diagonal unitary \operatorname{diag}(e^{i\arg(\mathrm{diag}[R^{\prime}R^{\dagger}])}) to align phases of R^{\prime} to R before computing the normalized root mean square error: \mathrm{NRMSE}(R,R^{\prime})=\frac{\sqrt{\frac{1}{N^{2}}\sum_{i,j}|R^{{}^{\prime}i}_{j}-R^{i}_{j}|^{2}}}{\frac{2}{N(N+1)}\sum_{i\leq j}|R^{i}_{j}|}. (8) Results in Figure 7 show that high fidelity decomposition is feasible with current experimental capabilities 12 . Figure 6: Column encoding via tunable \phi_{i} , \theta_{i} . The dominant component is set at \theta=\pi for exact amplitude realization. Figure 7: Normalized root mean square error (NRMSE) of the optical QR result R^{\prime} versus the ideal R , across matrix sizes N and bits of physical parameter precision. Shaded regions: 500 random Ginibre matrices, normalized by the largest coefficient magnitude; solid lines: mean values. VII Discussion We presented an analog, native QR factorization procedure based on programmable unitary optical meshes. The method uses local power concentration operations in tunable 2\times 2 blocks to self-configure a left unitary transformation U such that UA=R is upper triangular, yielding the standard factorization A=QR with Q=U^{\dagger} . The number of physical operations scales as O(N^{2}) , matching the intrinsic parameter count of a dense N\times N matrix and improving the O(N^{3}) arithmetic cost of digital QR decomposition algorithms. The same hardware ingredients support higher level routines. Our QR procedure leverages analog optics to replace sequential arithmetic with parallel interference. The device uses O(N^{2}) components with O(N) depth. After O(N^{2}) configuration operations, each matrix–vector multiply takes O(N) time (dominated by I/O, not propagation). Potentially this reduces matrix-matrix multiplication from O(N^{3}) to O(N^{2}) . Multiplexing can further accelerate throughput. Practical gains depend on hardware limits: loss, footprint, and phase precision cap the achievable N . In Appendix A we discuss modular tiling strategies that enable scaling to problem sizes beyond the capacity of a single photonic chip. While a rectangular mesh 10 offers higher density, its self-configuration currently incurs O(N^{3}) cost 17 (configuration of each 2\times 2 block requires new input vector), negating speedup. As it stands, the Givens array (Fig. 1 (d)) could be replaced by other power concentrating units (e.g., logarithmic trees), provided the inverse module (Fig. 3 (b)) is updated accordingly. In principle, the presented protocols also map to RF/microwave platforms using 50:50 hybrid couplers and tunable phase shifters (PIN diodes, varactors, etc.) 32 , offering higher power handling and mature fabrication. A recent quantum algorithm reports O(N^{2}\,\mathrm{poly}(\log N)) complexity 24 , however, it also relies on lower quantum memory resources on the order of \log(N) qubits (along with the usual assumptions about state preparation, oracle access, and measurement overhead). Our approach is classical and analog, relying on programmable interference of N optical channels rather than digital arithmetic. Finally, while presented for complex matrices, the approach applies to real valued target matrices. Acknowledgements. S.A.F. acknowledges the support from the Foundation for the Advancement of Theoretical Physics and Mathematics (BASIS) (Project № 23-2-10-15-1) and the Scholarships of the President of the Russian Federation for postgraduate students. Appendix A Modular Scaling Current photonic chips support only a few dozen channels. To scale, we propose tiling: interconnecting smaller d\times d tiles to form larger systems (Fig. 8 ). For the unitary mesh (Fig. 8 (a)), full parallel tiling with \sim N^{2}/(2d^{2}) tiles preserves the O(N^{2}) complexity of Section II . Alternatively, with a single tile reused sequentially, each placement configures O(d^{2}) elements, while injecting and reading N\cdot d amplitudes for each column. Since the full mesh has \sim N^{2}/2 T blocks, total cost is O\left(\frac{N^{2}}{d^{2}}(Nd+d^{2})\right)=O\left(\frac{N^{3}}{d}+N^{2}\right). (9) Choosing d\sim N^{\alpha} ( 0<\alpha\leq 1 ) yields O(N^{3-\alpha}) — better than the O(N^{3}) digital baseline. The X-bar stage (Fig. 8 (b)) also tiles naturally 29 : N columns encoding and fan-ins each scale as O(N) , and structured inputs (e.g., tridiagonal) can reduce this further. Figure 8: Tiling for scalability. (a) Unitary mesh tiling ( N=18 , d=6 ). (b) X-bar tiling with column encoding and fan-in. Skew indicates timing alignment needs at T blocks.