Tabular Matrix Problems via Pseudoinverse Estimation

The Tabular Matrix Problems via Pseudoinverse Estimation (TMPinv) is a two-stage estimation method that reformulates structured table-based systems - such as allocation problems, transaction matrices, and input-output tables - as structured least-squares problems. Based on the Convex Least Squares Programming (CLSP) framework of Bolotov (2025) , TMPinv solves systems with row and column constraints, known cells, block structure, and optionally reduced dimensionality by (1) constructing a canonical constraint form and applying a pseudoinverse-based projection, followed by (2) a convex-programming refinement stage to improve fit, coherence, and regularization (e.g., via Lasso, Ridge, or Elastic Net). Bounds on the cells, such as non-negativity, upper limits, fixed cells, or an exact zero diagonal, are enforced exactly; large tables can be estimated by block-coordinate sweeps over reduced submodels.


rtmpinv — Tabular Matrix Problems via Pseudoinverse Estimation

Tabular Matrix Problems via Pseudoinverse Estimation (TMPinv) is a two-step estimation method that reformulates structured table-based systems — such as allocation problems, transaction matrices and input–output tables — as structured least-squares problems. Based on the Convex Least Squares Programming (CLSP) framework, TMPinv solves systems with row and column constraints, block structure and optionally reduced dimensionality in two steps:

  1. it constructs a canonical constraint form and applies a pseudoinverse-based projection;
  2. a convex-programming correction stage selects, among the equally well-fitting solutions, the one closest to the pseudoinverse estimate in a Lasso, Ridge or Elastic Net sense.

Bounds on the cells (e.g. non-negativity, upper limits or fixed cells) are enforced exactly by CLSP; the totals and known values are fitted in least squares (see How TMPinv Works and Limitations). All calculations use double precision.

The method is described in Bolotov (2025), see Bibliography. Version 3.1.0 of rtmpinv implements the methodology of version 5.1.0 of the Python package pytmpinv (and, through rclsp 3.1.0, of pyclsp 5.1.0); the R-specific differences are listed below. Changes between versions are listed in NEWS.md.

Contents

Installation

install.packages("rtmpinv")

The package requires R ≥ 4.3 and depends on rclsp ≥ 3.1.0 (installed automatically, together with CVXR ≥ 1.9.3 and its solvers OSQP, CLARABEL and HiGHS).

How TMPinv Works

In Plain Terms

A tabular matrix problem asks for the cells of a table X ∈ ℝ^{m×p} when only some aggregate information is known: the row totals, the column totals and, possibly, some cells. The problem is usually underdetermined (there are more cells than totals) and, if the totals come from different sources, inconsistent (the row totals and the column totals do not add up to the same grand total).

tmpinv() writes the problem as an allocation problem (AP (TM)) of CLSP, rclsp::clsp(problem = "ap", ...), and returns the estimated table together with the fitted "clsp" object(s). CLSP solves it in two steps:

  1. Step 1 computes the minimum-norm least-squares solution with a pseudoinverse. If bounds on the cells are set, the bounded least-squares problem is solved instead (bounded-variable least squares, an active-set method that moves cells to and from their bounds; see Bounds).
  2. Step 2 keeps the best achievable fit of Step 1 fixed and, among all tables that attain it, chooses the one closest to the unbounded Step 1 estimate in a Lasso (L1), Ridge (L2) or Elastic Net sense, subject to the bounds (Step 2). With the default α = 1 (Ridge), this is the minimum-norm (bounded) least-squares table.

The totals and the known values are fitted in least squares:

  • Consistent rows. If they are consistent and compatible with the bounds, they are reproduced up to rounding, unless a cutoff rcond discards a direction needed to reproduce them (a feasible table then ends with ρ > 0 and a positive residual).
  • Inconsistent rows. Otherwise, they are traded off against each other.
  • Exact constraints. Only the bounds (and the signs of the slacks of S) are enforced exactly. A hard-constraint mode is not implemented in CLSP.

Problem Types

TMPinv covers the following variants of the problem, which can be combined:

  • Row and column totals (b_row, b_col): the sums of the rows and of the columns of X, both required (at least 2 entries each).
  • Grouped totals (i, j): each entry of b_row is the sum of i consecutive rows, each entry of b_col the sum of j consecutive columns, so that m = length(b_row)·i and p = length(b_col)·j.
  • Known values (M, b_val): linear restrictions on the cells, typically the selection of known cells (rows of an identity matrix) with their values in b_val.
  • Inequality totals (S): a total can be a "≤" or "≥" condition instead of an equality (a diagonal sign matrix, signed slacks).
  • Bounds (bounds): lower and/or upper bounds on all cells or on each cell, e.g. non-negativity c(0, NA); lo = hi fixes a cell.
  • Zero diagonal (zero_diagonal): x_kk = 0, e.g. for trade or flow matrices, as soft model rows (TRUE) or exactly via bounds ("exact"); see Zero Diagonal and Symmetry.
  • Symmetry (symmetric): a symmetric table, obtained by averaging the estimate with its transpose.
  • Reduced (block-wise) models (reduced): a large table is estimated block by block, by repeated sweeps over smaller problems on contiguous blocks (Reduced Models).

The Canonical Form

A z = b,      A = [ C  S ]      z = [ x ]      b = [ b_row ]
                  [ M  0 ]          [ y ]          [ b_col ]
                                                   [ b_val ]
  • x ∈ ℝ^{m·p} is X stored row by row (x[k] is the cell ((k − 1) %/% p + 1, (k − 1) %% p + 1)), returned as the m × p matrix result$x; the columns of M and the entries of bounds refer to this row-major order (as.vector(t(X))), not to R's column-major as.vector(X);
  • C are the constraint rows built by CLSP from m, p, i and j: length(b_row) row-sum rows followed by length(b_col) column-sum rows;
  • S (optional) holds the coefficients of the slacks y of the totals: S_kk = +1 makes total k a "≤" condition and S_kk = −1 a "≥" condition, since the slacks are restricted to y ≥ 0 (slack_sign = TRUE, the default when S is supplied);
  • M are the model rows with right-hand side b_val, e.g. the known cells; with zero_diagonal = TRUE, the rows x_kk = 0 are added to M (and the zeros to b) by CLSP;
  • the bounds lb ≤ x ≤ ub are not rows of A: they are constraints of both steps.

The fitted CLSP object is result$model (a list of "clsp" objects in the reduced model): model$A and model$b are the canonical system above, and model$status, model$rho and model$residual report the outcome of the fit (Example 6, Value). For the mathematical details of both steps, including the numerical-rank policy (rcond) and the verification of Step 2, see the rclsp documentation.

Bounds

bounds are passed to CLSP and enforced exactly in both steps:

  • in Step 1 by bounded-variable least squares (BVLS: the Lawson–Hanson active-set method in the bounded form of Stark and Parker, with pseudoinverse subproblems on the free cells), whose result is verified by the Karush–Kuhn–Tucker (KKT) conditions of the bounded least-squares problem; if the active set does not converge, the same problem is solved by a bounded least-squares fallback with CVXR (CLARABEL), with a warning;
  • in Step 2 as constraints of the convex program, whose solution is verified and clipped to the bounds.

An out-of-bound cell can therefore not occur in the CLSP estimate. A single pair c(lo, hi) applies to all cells, a list of m·p pairs (or an (m·p) × 2 matrix) to each cell; NA, NaN, NULL (inside a list pair) and ±Inf denote an unbounded side. If the totals and known values cannot be met within the bounds, the bounds are kept and the totals are fitted in least squares: model$rho > 0 is then the smallest residual attainable under the bounds (Example 2).

In version 2.0.0, bounds were handled by a heuristic: the cells within their bounds were frozen as known values (rows of M), the model was re-estimated, and the cells that remained out of bounds were replaced by replace_value (NA by default). This heuristic is removed in 3.0.0.

Step 2

With final = TRUE (the default), CLSP computes the fitted vector w* = A_k·zhat of the bounded least-squares problem of Step 1, where A_k is A with the singular values below the cutoff rcond set to zero (the retained system), its residual ρ = ‖b − w*‖₂ (model$rho), and the table

z* = argmin (1 − α)‖z − zhat0‖₁ + α‖z − zhat0‖₂²
     subject to   A_k z = w*,   lb ≤ x ≤ ub

where zhat0 is the unbounded Step 1 estimate (model$zhat0). All values of α attain the same residual ρ; α only selects among the equally well-fitting tables:

  • α = 1 (Ridge, the default) gives the unique minimum-norm (bounded) least-squares table;
  • α = 0 (Lasso) gives a table with the smallest L1 deviation from the anchor (not necessarily unique; Example 4);
  • 0 < α < 1 gives the Elastic Net.

Without bounds (and without signed slacks), Step 2 returns the Step 1 estimate for every α. α must be a single value in [0, 1]; it can be chosen by cross-validation over the model rows with rclsp::cv_alpha(result$model).

ρ is the smallest residual norm of the retained system under the bounds; model$residual = ‖b − Az‖₂ is the residual norm of the returned estimate on the original rows of A, which equals ρ (up to solver accuracy) unless singular values were discarded (a fallback to zhat has the same fitted vector w*). "optimal" in model$status$final means that Step 2 was solved and verified, not that the totals are met: an inconsistent table is "optimal" with ρ > 0 (Example 4).

Zero Diagonal and Symmetry

zero_diagonal sets the diagonal cells x_kk, k = 1, …, min(m, p), to zero in one of two ways:

  • Soft rows (TRUE). The rows x_kk = 0 are added as model rows, which CLSP fits in least squares like the totals: if the totals cannot be met with a zero diagonal, the diagonal cells become nonzero. A known value of a diagonal cell in M is kept together with its row x_kk = 0, so both are traded off (e.g. 2 × 2 totals of 2 and x₁₁ = 3 give x₁₁ = 1.2).
  • Exact zeros ("exact"). The bounds of the diagonal cells are set to c(0, 0), which makes them exactly zero; the misfit, if any, is then carried by the totals (Example 3). The bounds of the diagonal cells must admit 0.

symmetric = TRUE returns the symmetric table 0.5·(x + xᵀ) and requires m = p. The symmetrization is applied after the fit and to result$x only (not to result$model), so that:

  • the totals are reproduced by the symmetric table if b_row = b_col;
  • the bounds are preserved if they are symmetric (the bounds of the cells (k, l) and (l, k) are equal);
  • a known cell is preserved if its mirror cell is known with the same value.

For symmetry in the model itself, add symmetry rows x_kl − x_lk = 0 to M (with zeros in b_val) in a full-model solve.

Reduced (Block-Wise) Models

With reduced = c(r, c), the table is split into contiguous blocks of at most (r − 1) × (c − 1) cells, and the full problem is solved by block-coordinate (Gauss–Seidel) sweeps: in each sweep, every block is fitted in turn by CLSP as an AP (TM) problem with the other blocks fixed at their current values.

  • Totals. The row (column) totals of a block are the entries of b_row (b_col) minus the current sums of the other blocks' cells in these rows (columns), so that the blocks are linked through the totals of the full table.
  • Known values. M must consist of rows of the identity matrix. Repeated rows on the same cell (e.g. a known diagonal cell and x_kk = 0) are passed to the block of the cell as separate rows with their own values, as in the full model; their mean is used only for the start.
  • Bounds and zero diagonal. The bounds and an exact zero diagonal are mapped to the blocks; with zero_diagonal = TRUE, the zero diagonal is added as known zeros.
  • Start and stop. The sweeps start from the minimum-norm table of the totals, with the known values inserted and clipped to the bounds. They stop when the change of every cell between two sweeps is at most tolerance times its own scale, the larger of |x_ij| and the terms |b_k| + Σ |x| of its smallest row, column or known value, plus a rounding floor 30·eps·max(‖b‖₂, max |x|) (b: the totals and the known values), or after sweep_limit sweeps (default 100) with a warning. A tolerance of the largest cell, tolerance · max |x| (until version 3.0.1), stopped the 4 × 4 table diag(10⁸, 1, 1, 1), with its diagonal known, x ≥ 0 and reduced = c(3, 3), after 22 sweeps at 0, 0.22 and 0.22 on the unit diagonal instead of 1, while the unit cells still moved by up to 0.5 per sweep.
  • Slow contraction. While the last three sweeps contract steadily by a factor q (0.5 ≤ q < 1), a change within tolerance can still leave a distance of about q/(1 − q) times it to the fit, so that the change times q/(1 − q) must meet the rule. The table is then extrapolated along the last sweep by q/(1 − q) (clipped to the bounds); the extrapolation is undone if the next sweep changes the table more than the last one did, and the sweep from it does not end the sweeps.
  • Arguments. The arguments of rclsp::clsp() are passed to every block fit. S is ignored (with a warning), and grouped totals (i, j > 1) are not supported.

What the sweeps converge to. With r = 1, and if every block keeps the nonzero singular directions needed for its least-squares update (as the default cutoff does, which removes only numerically negligible singular values), each block fit minimizes the full least-squares objective (totals and known values) over the cells of the block. The sweeps are then block coordinate descent on a convex problem and converge toward a least-squares fit of the full problem, which reproduces consistent totals within the bounds (Example 5).

The returned table is the last sweep, i.e. this fit up to the stopping rule. If the full problem has several least-squares solutions (the usual case), the sweeps reach one of them, not necessarily the minimum-norm (Step 2) solution of the full model.

Cutoff per block. A cutoff rcond is applied to each block separately, so that the sweeps then fit another objective than the full model with the same cutoff, and the result depends on the partition (a counterexample is in Limitations).

One block and r > 1. With one block, the reduced model equals the full model (without S) for every r. With more than one block, r > 1 signals a tmpinvError: every block fit would build its residual slacks Q from the residuals of its own model rows, given the current values of the other blocks, so that the objective would change between the block updates and the sweeps would not minimize a common objective.

For example, a 4 × 4 table with unit totals, a known unit diagonal and x ≥ 0, whose only solution is the identity, gave 0.625 on the diagonal with every block 'optimal'.

Cost and results. A sweep costs one CLSP fit per block, i.e. an SVD of a (r − 1 + c − 1 + k_block) × (r − 1)(c − 1) matrix instead of one of the full (m + p + k) × m·p matrix. The number of sweeps (result$sweeps) depends on the problem (a few to a few dozen in the examples). The tolerances scale with the cells, the totals and the known values, so that the units of the table hardly change it (the 4 × 4 table above takes 27 sweeps in units of 10⁻⁹, 1 and 10⁶). result$model holds the block fits of the last sweep.

Check. When the sweeps stop, every total and known value of the table is compared with its tolerance, sqrt(tolerance) times its terms (as the row check of CLSP) plus 4 times the tolerances of the stopping rule of its cells. If one is unmet while the row and column totals agree (their sums differ by at most the smallest tolerance of a total), a warning is issued: known values or bounds conflict with the totals, or the sweeps stopped far from the fit. Totals that disagree cannot be met by any table, and their least-squares fit, as in the full model, is not warned about.

result$converged is TRUE if the sweeps met the stopping rule, every block fit of the last sweep converged and no cell was replaced; it does not cover the totals and known values (an inconsistent table also converges). result$check holds the stopping criterion of the last sweep, change (the largest change of a cell in units of its tolerance, times q/(1 − q) of a slow contraction), and residual, the largest residual of a total or known value of result$x in units of its tolerance (≤ 1: met).

Symmetry. symmetric = TRUE averages the table after the sweeps with its transpose. For a symmetric problem (b_row = b_col, symmetric known values and bounds), the average is again a least-squares fit, but, like the sweeps, not necessarily the one of the full model. result$check$residual describes the symmetrized table (which can miss a known value whose mirror cell differs, as in the full model), the warning of the check the table of the sweeps.

replace_value

Since the bounds are enforced by CLSP, replace_value no longer replaces out-of-bound values of the fit. It applies only to

  • the cells of a (full or block) model whose bounded Step 1 did not converge (in the reduced model, a block fit of the last sweep), i.e. model$status$step1 starts with "not converged": both the active-set method and the CVXR fallback failed, and CLSP kept the last feasible point, which is not a verified least-squares solution;
  • the cells that violate their bounds by more than tolerance after the symmetrization (symmetric = TRUE with asymmetric bounds, Example 7).

The default NA_real_ marks these cells as missing; NULL keeps the estimate. The replaced cells are reported in the logical matrix result$replaced (all FALSE for a converged fit), and result$model keeps the unreplaced CLSP estimate. In the reduced model, a replaced cell sets result$converged to FALSE and result$check$residual to NaN.

Examples

Each example below is self-contained; the output shown was produced by running it with rtmpinv 3.1.0 and rclsp 3.1.0 (R 4.5.3, CVXR 1.9.3, S7 1.0.0, macOS arm64; the last digits of solver-dependent values may differ across platforms and solver versions). The random tables are drawn with R's random number generator and differ from those of the pytmpinv examples.

1. Quick Example: an Input-Output-Type Table with x ≥ 0 and Known Cells

library(rtmpinv)

# AP (TM), based on a symmetric input-output-type table with known cell
# pairs and x >= 0

set.seed(1)

# sample (dataset)
m      <- 8; p <- 8                            # matrix dimensions (m x p)
X_true <- abs(matrix(rnorm(m * p), m, p))      # non-negative X_true
X_true[matrix(runif(m * p), m, p) < 0.4] <- 0  # empty cells
X_true <- (X_true + t(X_true)) / 2             # symmetric X_true
# 15% of the cells (row-major), with their mirror cells
idx    <- sample.int(m * p, floor(0.15 * m * p))
idx    <- sort(unique(c(idx, ((idx - 1) %% p) * p +
                             (idx - 1) %/% p + 1)))

# model
M      <- diag(m * p)[idx, ]                   # rows of the identity matrix
b_row  <- rowSums(X_true)                      # row sums (length m)
b_col  <- colSums(X_true)                      # column sums (length p)
b_val  <- as.vector(t(X_true))[idx]            # known values (row-major)
result <- tmpinv(
              M = M, b_row = b_row, b_col = b_col, b_val = b_val,
              bounds = c(0, NA),               # x >= 0, enforced exactly
              symmetric = TRUE,
              alpha = 1                        # unique, minimum-norm
          )

# the same model without bounds
x_free <- tmpinv(M = M, b_row = b_row, b_col = b_col,
                 b_val = b_val, symmetric = TRUE)$x

# results
cat("true X:\n");  print(round(X_true, 4))
cat("X_hat:\n");   print(round(result$x, 4))
cat("min(X_hat)             :", min(result$x), "\n")
cat("min(X_hat), unbounded  :", round(min(x_free), 4), "\n")
cat("max |row sums - b_row| :",
    sprintf("%.2e", max(abs(rowSums(result$x) - b_row))), "\n")
cat("max |col sums - b_col| :",
    sprintf("%.2e", max(abs(colSums(result$x) - b_col))), "\n")
cat("max |known - b_val|    :", sprintf("%.2e",
    max(abs(as.vector(t(result$x))[idx] - b_val))), "\n")
cat("status:", result$model$status$step1, "/", result$model$status$final,
    "/", result$model$status$solver, "\n")
cat(sprintf("rho = %.2e, residual = %.2e, replaced = %d\n",
            result$model$rho, result$model$residual, sum(result$replaced)))

ss_res <- sum((X_true - result$x)^2)
ss_tot <- sum((X_true - mean(X_true))^2)
cat(sprintf("R2_user_defined: %.4f\n", 1 - ss_res / ss_tot))

Output:

true X:
       [,1]   [,2]   [,3]   [,4]   [,5]   [,6]   [,7]   [,8]
[1,] 0.0000 0.3797 0.4259 0.0000 0.0000 0.4925 0.2999 0.5528
[2,] 0.3797 0.3054 1.2278 0.2230 0.3375 1.1073 0.4406 0.0000
[3,] 0.4259 1.2278 0.0000 0.3748 0.6885 0.7395 0.2363 1.2795
[4,] 0.0000 0.2230 0.3748 0.0000 0.4466 0.2783 0.3060 0.0675
[5,] 0.0000 0.3375 0.6885 0.4466 0.3943 0.3740 0.0000 1.2008
[6,] 0.4925 1.1073 0.7395 0.2783 0.3740 0.0000 0.0000 0.4039
[7,] 0.2999 0.4406 0.2363 0.3060 0.0000 0.0000 1.4330 1.3351
[8,] 0.5528 0.0000 1.2795 0.0675 1.2008 0.4039 1.3351 0.0000
X_hat:
       [,1]   [,2]   [,3]   [,4]   [,5]   [,6]   [,7]   [,8]
[1,] 0.0000 0.3797 0.4594 0.0000 0.2038 0.4925 0.2912 0.3242
[2,] 0.3797 0.5810 0.8251 0.1356 0.3375 0.4156 0.6569 0.6899
[3,] 0.4594 0.8251 0.0000 0.3797 0.8136 0.6597 0.9010 0.9340
[4,] 0.0000 0.1356 0.3797 0.0000 0.4466 0.2783 0.2115 0.2445
[5,] 0.2038 0.3375 0.8136 0.4466 0.5579 0.4040 0.0000 0.6784
[6,] 0.4925 0.4156 0.6597 0.2783 0.4040 0.2501 0.4915 0.4039
[7,] 0.2912 0.6569 0.9010 0.2115 0.0000 0.4915 0.7328 0.7658
[8,] 0.3242 0.6899 0.9340 0.2445 0.6784 0.4039 0.7658 0.7988
min(X_hat)             : 0 
min(X_hat), unbounded  : -0.1546 
max |row sums - b_row| : 7.11e-15 
max |col sums - b_col| : 7.11e-15 
max |known - b_val|    : 1.39e-15 
status: converged / optimal / OSQP 
rho = 3.43e-15, residual = 2.13e-14, replaced = 0
R2_user_defined: 0.3958

Without bounds, the minimum-norm estimate contains negative cells (−0.1546). With bounds = c(0, NA), the estimate is non-negative exactly, and the totals and the known cells (chosen in mirror pairs, so that the symmetrization preserves them) are reproduced up to rounding, since they are consistent: ρ ≈ 0. With only the totals and 16 known cells for 64 unknowns, the estimate is the minimum-norm non-negative table consistent with this information, not the true table (R² = 0.3958).

2. Lower, Upper and Cell-Specific Bounds

library(rtmpinv)

# AP (TM) 3 x 3 with known row and column sums: lower, upper and
# cell-specific bounds

b_row     <- c(1, 10, 10)                      # row sums
b_col     <- c(1, 10, 10)                      # column sums
lohi      <- rep(list(c(0, NA)), 9)            # x >= 0 for all cells,
lohi[[5]] <- c(0, 4.5)                         # x_22 <= 4.5,
lohi[[9]] <- c(5, 5)                           # x_33 = 5 (a fixed cell)
cases     <- list("unbounded       " = NULL,
                  "bounds = c(0, NA)" = c(0, NA),
                  "cell-specific   " = lohi,
                  # infeasible with the totals
                  "bounds = c(0, 4.6)" = c(0, 4.6))
for (label in names(cases)) {
  result <- tmpinv(b_row = b_row, b_col = b_col, bounds = cases[[label]])
  model  <- result$model
  cat(sprintf("%s: step1 = %s, rho = %.4f, residual = %.4f\n", label,
              model$status$step1, model$rho, model$residual))
  print(round(result$x, 4))
  cat("  row sums:", round(rowSums(result$x), 4),
      " column sums:", round(colSums(result$x), 4), "\n")
}

Output:

unbounded       : step1 = converged, rho = 0.0000, residual = 0.0000
        [,1]   [,2]   [,3]
[1,] -1.6667 1.3333 1.3333
[2,]  1.3333 4.3333 4.3333
[3,]  1.3333 4.3333 4.3333
  row sums: 1 10 10  column sums: 1 10 10 
bounds = c(0, NA): step1 = converged, rho = 0.0000, residual = 0.0000
     [,1] [,2] [,3]
[1,]  0.0 0.50 0.50
[2,]  0.5 4.75 4.75
[3,]  0.5 4.75 4.75
  row sums: 1 10 10  column sums: 1 10 10 
cell-specific   : step1 = converged, rho = 0.0000, residual = 0.0000
     [,1] [,2] [,3]
[1,] 0.00 0.75 0.25
[2,] 0.75 4.50 4.75
[3,] 0.25 4.75 5.00
  row sums: 1 10 10  column sums: 1 10 10 
bounds = c(0, 4.6): step1 = converged, rho = 0.4899, residual = 0.4899
     [,1] [,2] [,3]
[1,]  0.0  0.6  0.6
[2,]  0.6  4.6  4.6
[3,]  0.6  4.6  4.6
  row sums: 1.2 9.8 9.8  column sums: 1.2 9.8 9.8 

The unbounded minimum-norm estimate has a negative cell. With bounds = c(0, NA), the cell x_11 is fixed at 0 and the other cells are re-estimated, so that the totals are met exactly. The cell-specific bounds hold exactly as well (x_22 = 4.5 at its upper bound, x_33 = 5 fixed), again with the totals met.

With bounds = c(0, 4.6), no table meets the totals (rows 2 and 3 must sum to 20, but column 1 contributes at most 1 and their other four cells at most 4 · 4.6 = 18.4): the bounds still hold exactly, and the totals are fitted in least squares with the smallest attainable residual ρ = 0.4899.

3. A Zero Diagonal: Soft Rows vs. Exact Zeros

library(rtmpinv)

# AP (TM) 3 x 3 with x >= 0: a zero diagonal as soft model rows vs. exact
# zeros via bounds

b_row <- c(10, 1, 1)                           # row sums
b_col <- c(10, 1, 1)                           # column sums
for (zero_diagonal in list(TRUE, "exact")) {
  result <- tmpinv(b_row = b_row, b_col = b_col, bounds = c(0, NA),
                   zero_diagonal = zero_diagonal)
  cat(sprintf("zero_diagonal = %s: rho = %.4f\n", deparse(zero_diagonal),
              result$model$rho))
  print(round(result$x, 4))
  cat("  row sums:", round(rowSums(result$x), 4),
      " column sums:", round(colSums(result$x), 4), "\n")
}

# AP (TM) 5 x 5 trade matrix with a zero diagonal and feasible totals

set.seed(42)
X_true <- matrix(runif(25, 0, 2), 5, 5) * (1 - diag(5))  # zero diagonal
result <- tmpinv(b_row = rowSums(X_true), b_col = colSums(X_true),
                 bounds = c(0, NA), zero_diagonal = "exact")
cat("5 x 5, zero_diagonal = \"exact\": diagonal =", diag(result$x),
    sprintf(" residual = %.1e\n", result$model$residual))

Output:

zero_diagonal = TRUE: rho = 5.0596
     [,1] [,2] [,3]
[1,]  3.2  2.6  2.6
[2,]  2.6  0.0  0.0
[3,]  2.6  0.0  0.0
  row sums: 8.4 2.6 2.6  column sums: 8.4 2.6 2.6 
zero_diagonal = "exact": rho = 6.5320
       [,1]   [,2]   [,3]
[1,] 0.0000 3.6667 3.6667
[2,] 3.6667 0.0000 0.0000
[3,] 3.6667 0.0000 0.0000
  row sums: 7.3333 3.6667 3.6667  column sums: 7.3333 3.6667 3.6667 
5 x 5, zero_diagonal = "exact": diagonal = 0 0 0 0 0  residual = 3.6e-15

Non-negative cells cannot meet these totals with a zero diagonal (row 1 must sum to 10 without x_11, but its other cells lie in columns 2 and 3, which sum to 1 each):

  • zero_diagonal = TRUE adds the rows x_kk = 0 as model rows, which are traded off against the totals: x_11 = 3.2.
  • zero_diagonal = "exact" fixes the diagonal at 0 through the bounds; the misfit is then carried by the totals alone (ρ = 6.5320 > 5.0596).

If the totals are compatible with a zero diagonal, as in the 5 × 5 trade matrix, they are met exactly with an exactly zero diagonal.

4. Inconsistent Totals: ρ, Residual and Status

library(rtmpinv)

# AP (TM) 3 x 3 with inconsistent totals (row sums: 21, column sums: 22)

b_row <- c(1, 10, 10)                          # row sums
b_col <- c(1, 10, 11)                          # column sums
for (case in list(list(NULL, 1), list(c(0, NA), 0), list(c(0, NA), 0.5),
                  list(c(0, NA), 1))) {
  result <- tmpinv(b_row = b_row, b_col = b_col, bounds = case[[1]],
                   alpha = case[[2]])
  model  <- result$model
  cat(sprintf(
    "bounds = %s, alpha = %s: step1 = %s, final = %s, solver = %s\n",
    deparse(case[[1]]), case[[2]], model$status$step1,
    model$status$final, model$status$solver))
  cat(sprintf("  rho = %.4f, residual = %.4f, nrmse = %.4f\n", model$rho,
              model$residual, model$nrmse))
  print(round(result$x, 4))
  cat("  row sums:", round(rowSums(result$x), 4),
      " column sums:", round(colSums(result$x), 4), "\n")
}

Output:

bounds = NULL, alpha = 1: step1 = converged, final = optimal, solver = none (anchor feasible)
  rho = 0.4082, residual = 0.4082, nrmse = 0.0381
        [,1]   [,2]   [,3]
[1,] -1.7222 1.2778 1.6111
[2,]  1.2778 4.2778 4.6111
[3,]  1.2778 4.2778 4.6111
  row sums: 1.1667 10.1667 10.1667  column sums: 0.8333 9.8333 10.8333 
bounds = c(0, NA), alpha = 0: step1 = converged, final = optimal, solver = CLARABEL
  rho = 0.4082, residual = 0.4082, nrmse = 0.0381
       [,1]   [,2]   [,3]
[1,] 0.0000 0.4544 0.7123
[2,] 0.4167 4.6895 5.0605
[3,] 0.4167 4.6895 5.0605
  row sums: 1.1667 10.1667 10.1667  column sums: 0.8333 9.8333 10.8333 
bounds = c(0, NA), alpha = 0.5: step1 = converged, final = optimal, solver = CLARABEL
  rho = 0.4082, residual = 0.4082, nrmse = 0.0381
       [,1]   [,2]   [,3]
[1,] 0.0000 0.4167 0.7500
[2,] 0.4167 4.7083 5.0417
[3,] 0.4167 4.7083 5.0417
  row sums: 1.1667 10.1667 10.1667  column sums: 0.8333 9.8333 10.8333 
bounds = c(0, NA), alpha = 1: step1 = converged, final = optimal, solver = OSQP
  rho = 0.4082, residual = 0.4082, nrmse = 0.0381
       [,1]   [,2]   [,3]
[1,] 0.0000 0.4167 0.7500
[2,] 0.4167 4.7083 5.0417
[3,] 0.4167 4.7083 5.0417
  row sums: 1.1667 10.1667 10.1667  column sums: 0.8333 9.8333 10.8333 

The row totals (21) and column totals (22) cannot both be met, so they are fitted in least squares: ρ = 0.4082 is the smallest attainable residual, with or without x ≥ 0 here, and every α attains it (residual = rho). Without bounds, Step 2 does not change the minimum-norm estimate (the anchor is feasible, so no solver is called).

With x ≥ 0, α selects among the equally well-fitting non-negative tables. The Lasso (α = 0) minimizer is not unique here: many tables attain the smallest L1 distance to the anchor (6.8889, attained also by the Elastic Net and Ridge table), and the solver (CLARABEL, the default for α = 0 in rclsp and pyclsp) returns one of them. The printed Lasso table is therefore one possible solution and can differ between rclsp versions, solvers and platforms (and from pytmpinv); ρ and the L1 distance do not. status reports the outcome of the bounded Step 1 (step1), of Step 2 (final) and the solver used.

5. Reduced (Block-Wise) Models

library(rtmpinv)

# AP (TM), based on a 40 x 40 trade matrix with a zero diagonal and 20%
# of known values, estimated as reduced models of (20, 20), i.e. 3 x 3
# blocks of at most 19 x 19 cells

set.seed(123456789)

# sample (dataset)
m      <- 40; p <- 40                          # matrix dimensions (m x p)
X_true <- abs(matrix(rnorm(m * p), m, p))      # non-negative X_true
X_true <- X_true * (1 - diag(m))               # zero diagonal
# 20% of the cells (row-major)
idx    <- sample.int(m * p, floor(0.2 * m * p))

# model
M      <- diag(m * p)[idx, ]                   # rows of the identity
b_row  <- rowSums(X_true)                      # row sums (length m)
b_col  <- colSums(X_true)                      # column sums (length p)
b_val  <- as.vector(t(X_true))[idx]            # known values (row-major)
result <- tmpinv(
              M = M, b_row = b_row, b_col = b_col, b_val = b_val,
              bounds = c(0, NA),               # x >= 0
              zero_diagonal = "exact",         # x_kk = 0 via bounds
              reduced = c(20, 20)              # reduced models of (20, 20)
          )

# results
shapes <- unique(t(vapply(result$model, function(v) dim(v$x),
                          integer(2))))
cat("blocks:", length(result$model), " shapes:",
    paste0("(", shapes[, 1], ", ", shapes[, 2], ")"), "\n")
cat("sweeps:", result$sweeps, "\n")
cat("step1 :", unique(vapply(result$model, function(v) v$status$step1,
                             "")),
    " final:", unique(vapply(result$model, function(v) v$status$final,
                             "")), "\n")
cat("min(X_hat) =", min(result$x), " max |diag(X_hat)| =",
    max(abs(diag(result$x))), "\n")
cat("max |known - b_val|:",
    sprintf("%.1e", max(abs(as.vector(t(result$x))[idx] - b_val))), "\n")
cat("max relative error of the totals:",
    sprintf("%.1e", max(abs(rowSums(result$x) / b_row - 1),
                        abs(colSums(result$x) / b_col - 1))), "\n")

ss_tot <- sum((X_true - mean(X_true))^2)
cat(sprintf("R2_user_defined: %.4f\n",
            1 - sum((X_true - result$x)^2) / ss_tot))

# the full model, for comparison
full   <- tmpinv(M = M, b_row = b_row, b_col = b_col, b_val = b_val,
                 bounds = c(0, NA), zero_diagonal = "exact")
cat(sprintf(paste0(
  "full model: R2_user_defined = %.4f, max |X_hat - X_full| = %.4f, ",
  "||X_hat|| / ||X_full|| = %.4f\n"),
  1 - sum((X_true - full$x)^2) / ss_tot, max(abs(result$x - full$x)),
  sqrt(sum(result$x^2)) / sqrt(sum(full$x^2))))

Output:

blocks: 9  shapes: (19, 19) (19, 2) (2, 19) (2, 2) 
sweeps: 22 
step1 : converged  final: optimal 
min(X_hat) = 0  max |diag(X_hat)| = 0 
max |known - b_val|: 6.0e-10 
max relative error of the totals: 1.8e-11 
R2_user_defined: 0.2814
full model: R2_user_defined = 0.2915, max |X_hat - X_full| = 0.2503, ||X_hat|| / ||X_full|| = 1.0026

The 40 × 40 table is estimated as 9 blocks (19 + 19 + 2 rows and columns) in 22 sweeps (pytmpinv 5.1.0 takes the same 22 sweeps on this table). The bounds (x ≥ 0 and the exact zero diagonal) hold, and the totals and the known values are reproduced up to the convergence tolerance of the sweeps.

  • Fit. The estimate is a least-squares fit of the full problem, but not the minimum-norm one selected by the full model: it is slightly larger in norm and differs from the full-model estimate by up to 0.25 per cell (R² = 0.2814 vs. 0.2915).
  • Time. A sweep costs one CLSP fit per block, so that the reduced model is slower than the full model for a table of this size (here, 2 to 3.5 times, depending on the number of BLAS threads). It pays off for larger tables (for an 80 × 80 table with 16 blocks, 9 sweeps took a sixth to a quarter of the time of the full model) and for tables that are too large for the full model (see Limitations).

In version 2.0.0, the blocks were fitted independently, each with one slack per total, so that the assembled table did not reproduce the totals of the full table.

6. Reading the Results and Diagnostics

library(rtmpinv)

# AP (TM) 5 x 5 with x >= 0 and 6 noisy known values (an inconsistent
# system), followed by the results

set.seed(4)

# sample (dataset)
m      <- 5; p <- 5                            # matrix dimensions (m x p)
X_true <- matrix(runif(m * p, 0, 3), m, p)
X_true[matrix(runif(m * p), m, p) < 0.3] <- 0  # empty cells
idx    <- sample.int(m * p, 6)                 # known cells (row-major)

# model
result <- tmpinv(
              M = diag(m * p)[idx, ],
              b_val = as.vector(t(X_true))[idx] + 0.3 * rnorm(6),
              b_row = rowSums(X_true), b_col = colSums(X_true),
              bounds = c(0, NA)
          )
model  <- result$model                         # the "clsp" object

# results
cat("X_hat:\n"); print(round(result$x, 4))
cat(sprintf("rho = %.4f, residual = %.4f, rank = %d of %d\n", model$rho,
            model$residual, model$rank, ncol(model$A)))
for (key in c("step1", "rho", "final", "solver", "retry", "kkt_error",
              "bound_error", "eq_error")) {
  val <- model$status[[key]]
  cat(sprintf("  %-12s %s\n", key, if (is.null(val)) "NULL" else
              if (is.numeric(val)) sprintf("%.1e", val) else val))
}
print(summary(result))
cat("  Bootstrap t-test (NRMSE_partial):\n")
tt <- rclsp::ttest(model, sample_size = 30, seed = 4, partial = TRUE)
for (key in names(tt))
  cat(sprintf("    %s: %.6f\n", key, as.numeric(tt[[key]])))

Output:

X_hat:
       [,1]   [,2]   [,3]   [,4]   [,5]
[1,] 1.4135 1.6213 1.8014 1.3319 0.0000
[2,] 0.4901 0.6979 0.8780 0.2802 1.5285
[3,] 1.2055 2.5969 0.0000 1.1240 2.2439
[4,] 1.4422 1.6500 1.8301 1.3607 1.7282
[5,] 1.3870 0.0000 1.7749 1.3055 2.4254
rho = 0.1599, residual = 0.1599, rank = 15 of 25
  step1        converged
  rho          bvls
  final        optimal
  solver       OSQP
  retry        NULL
  kkt_error    1.4e-16
  bound_error  0.0e+00
  eq_error     8.9e-16
Estimator Configuration:
  Generalized inverse:   Moore-Penrose
  Iterations (r):                    1
  Tolerance:                 1.490e-08
  Final correction:               TRUE
  Regularization (α):           1.0000
  Bounds (x):                 [0, Inf]
  Slack sign (S ≥ 0):            FALSE
  Column scaling:                FALSE
  Fixed variables:                   3

Numerical Stability:
  kappaC:                       1.4142
  kappaB:                       1.0622
  kappaA:                       5.7229
  rank:                             15

Goodness of Fit:
  r2_partial:                   0.9961
  nrmse:                        0.0134
  nrmse_partial:                0.0621
  z_lower:        min= 0.000e+00  max=    2.4831  mean=    1.2284  sd=    0.6885
  z_upper:        min= 0.000e+00  max=    2.7108  mean=    1.3410  sd=    0.7517
  x_lower:        min= 0.000e+00  max=    2.4831  mean=    1.2284  sd=    0.6885
  x_upper:        min= 0.000e+00  max=    2.7108  mean=    1.3410  sd=    0.7517
  y_lower:        min=       NaN  max=       NaN  mean=       NaN  sd=       NaN
  y_upper:        min=       NaN  max=       NaN  mean=       NaN  sd=       NaN
  Bootstrap t-test (NRMSE_partial):
    p_one_left: 0.884657
    p_one_right: 0.115343
    p_two_sided: 0.230686
    nrmse: 0.062120
    mean_null: 0.055498
    std_null: 0.029625
    failures: 0.000000

The noisy known values are inconsistent with the totals under x ≥ 0, so ρ = 0.1599 > 0. result$model is the "clsp" object of the fit: its status reports a converged bounded Step 1 (step1, kkt_error) and a verified Step 2 (final, eq_error), and summary() prints the estimator configuration (3 cells at the bound 0 in Step 1), the condition numbers and the goodness of fit.

The bootstrap t-test compares the observed NRMSE of the model rows with a resampled null sample; it and the sensitivity bands are heuristic diagnostics (see Limitations).

Element Meaning
result$x estimated m × p table (symmetrized if symmetric = TRUE, with replace_value in the replaced cells)
result$replaced logical m × p matrix of the cells set to replace_value
result$full TRUE for the full model, FALSE for the reduced model
result$model "clsp" object (full model) or list of "clsp" objects, one per block (reduced model)
result$sweeps number of block sweeps (reduced model; NULL in the full model)
result$converged, result$check whether the sweeps settled, and their stopping criterion and largest residual in units of their tolerances (reduced model; NULL in the full model)
model$x CLSP estimate of the (block) table, before the symmetrization and the replacement
model$rho smallest residual ‖b − w*‖₂ attainable under the bounds (NULL if final = FALSE)
model$residual ‖b − Az‖₂ of the returned estimate
model$status$step1 "converged", "bvls fallback" (the CVXR fallback solved the bounded problem) or "not converged: <reason>"
model$status$final "optimal" or "optimal_inaccurate" (verified), "fallback: <reason>" (z = zhat) or "skipped"
model$zhat, model$zhat0 Step 1 estimate (bounded) and the unbounded Step 1 estimate, the anchor of Step 2
model$fixed, model$fixed_at components of z in the final working set of Step 1 (fixed at a bound) (logical), and the pass at which they were fixed
model$A, model$b canonical system of the fit

A fit is usable as intended if status$step1 is "converged" or "bvls fallback" and status$final does not start with "fallback".

7. replace_value and replaced

library(rtmpinv)

# AP (TM) 3 x 3 symmetric table with an asymmetric cell-specific bound:
# replace_value

X_true    <- matrix(c(0, 2, 1,
                      2, 0, 3,
                      1, 3, 0), 3, byrow = TRUE)
lohi      <- rep(list(c(0, NA)), 9)            # x >= 0
lohi[[2]] <- c(0, 0.1)                         # x_12 <= 0.1, but not x_21
for (replace_value in list(NA_real_, NULL)) {
  result <- tmpinv(b_row = rowSums(X_true), b_col = colSums(X_true),
                   bounds = lohi, symmetric = TRUE,
                   replace_value = replace_value)
  rc     <- which(result$replaced, arr.ind = TRUE)  # replaced cells
  rc     <- rc[order(rc[, 1], rc[, 2]), , drop = FALSE]
  cat("replace_value =", deparse(replace_value), ": replaced cells =",
      if (nrow(rc)) sprintf("(%d, %d)", rc[, 1], rc[, 2]) else "none", "\n")
  print(round(result$x, 4))
}
cat("CLSP estimate before the symmetrization (x_12 <= 0.1 holds):\n")
print(round(result$model$x, 4))

Output:

replace_value = NA_real_ : replaced cells = (1, 2) (2, 1) 
       [,1]   [,2]   [,3]
[1,] 1.2833     NA 1.1542
[2,]     NA 2.6167 1.8208
[3,] 1.1542 1.8208 1.0250
replace_value = NULL : replaced cells = none 
       [,1]   [,2]   [,3]
[1,] 1.2833 0.5625 1.1542
[2,] 0.5625 2.6167 1.8208
[3,] 1.1542 1.8208 1.0250
CLSP estimate before the symmetrization (x_12 <= 0.1 holds):
       [,1]   [,2]   [,3]
[1,] 1.2833 0.1000 1.6167
[2,] 1.0250 2.6167 1.3583
[3,] 0.6917 2.2833 1.0250

The bound x_12 ≤ 0.1 holds in the CLSP estimate (result$model$x), but not after the symmetrization, since the mirror cell x_21 is not bounded: the average 0.5625 violates the bound. With the default replace_value = NA_real_, the two cells are replaced and marked in result$replaced; with replace_value = NULL, the symmetric estimate is kept as it is. Symmetric bounds (equal bounds for x_12 and x_21) avoid the conflict.

User Reference

For comprehensive information on the estimator's capabilities, advanced configuration options and implementation details, please refer to the rclsp package, on which TMPinv is based, and to ?tmpinv.

To ensure cross-platform reproducibility, all CLSP implementations use a modified condition number function based on singular values, with relative cutoff cond_tolerance. The corresponding absolute threshold is cond_tolerance * the largest singular value.

library(rtmpinv)
result <- tmpinv(S = NULL, M = NULL, b_row = NULL, b_col = NULL, b_val = NULL,
                 i = 1L, j = 1L, zero_diagonal = FALSE, reduced = NULL,
                 symmetric = FALSE, bounds = NULL, replace_value = NA_real_,
                 tolerance = sqrt(.Machine$double.eps), iteration_limit = 50L,
                 r = 1L, final = NULL, alpha = NULL, cond_tolerance = NULL,
                 slack_sign = NULL, sweep_limit = 100L, ...)

tmpinv() normalizes bounds, builds the CLSP problem(s) (the full model or the block fits of the sweeps) and applies replace_value.

TMPinv Arguments

S : numeric matrix with length(b_row) + length(b_col) rows, optional
A diagonal sign slack (surplus) matrix with entries in {0, ±1} (a zero-padded subset of ±I; zero columns may be omitted, and an S without columns is S = NULL):

  • 0 enforces equality (== b_row or b_col),
  • 1 enforces a lower-than-or-equal (≤) condition,
  • –1 enforces a greater-than-or-equal (≥) condition.

The first length(b_row) rows correspond to the row totals, and the remaining length(b_col) rows to the column totals. The conditions are imposed through slacks y ≥ 0 (slack_sign, TRUE by default when S is supplied): a total with S_kk = ±1 is free on its feasible side and remains a least-squares row on its infeasible side. Please note that, in the reduced model, S is ignored.

M : numeric matrix of size k × (m·p), optional
A model matrix with entries in {0, 1}. Each row defines a linear restriction on the solution matrix stored row by row (row-major; cell (r, c) is column (r − 1)·p + c). The corresponding right-hand side values must be provided in b_val. This block is used to encode known cell values (least-squares rows, like the totals).

Please note that, in the reduced model, M must consist of rows of an identity matrix (known cells; a cell may repeat). Arbitrary or non-diagonal model matrices cannot be mapped to reduced blocks.

b_row : numeric vector
Right-hand side vector of row totals (of row groups if i > 1). Please note that both b_row and b_col must be provided, with at least 2 finite entries each.

b_col : numeric vector
Right-hand side vector of column totals (of column groups if j > 1). Please note that both b_row and b_col must be provided, with at least 2 finite entries each. Each is a numeric vector (also a matrix of one row or column); arrays of more dimensions and factors signal a tmpinvError (a 2 × 2 × 2 array was read as 8 totals, and a factor as its level codes).

b_val : numeric vector of length k
Right-hand side vector of known cell values (finite).

i : integer, default = 1
Number of rows in a row group: each entry of b_row is the sum of i consecutive rows, and the table has m = length(b_row) · i rows. Not supported in the reduced model.

j : integer, default = 1
Number of columns in a column group: each entry of b_col is the sum of j consecutive columns, and the table has p = length(b_col) · j columns. Not supported in the reduced model.

zero_diagonal : logical or "exact", default = FALSE
If TRUE, adds the soft model rows x_kk = 0 for the diagonal cells (least-squares rows, traded off against the totals in an inconsistent system). If "exact", sets the bounds of the diagonal cells to c(0, 0), which makes them exactly zero; their bounds in bounds must admit 0.

reduced : integer vector of length 2, optional
Dimensions of the reduced problem. If specified, the problem is estimated by block-coordinate sweeps over contiguous submatrices of the original table. For example, reduced = c(6, 6) implies 5×5 data blocks (edge blocks may be smaller). Each dimension must be at least 3. See Reduced Models.

sweep_limit : integer, default = 100
Maximum number of block sweeps in the reduced model (ignored in the full model). The sweeps stop when the change of every cell between two sweeps is at most tolerance times its own scale plus a rounding floor (times q/(1 − q) while they contract slowly by a factor q; Reduced Models); if this is not reached within sweep_limit sweeps, a warning is issued and the last table is returned (result$converged FALSE). The number of sweeps performed is result$sweeps.

symmetric : logical, default = FALSE
If TRUE, enforces symmetry of the estimated solution matrix as x = 0.5 * (x + t(x)), which requires m = p. Applies to result$x only (after the sweeps in the reduced model). For symmetry of result$model, add explicit symmetry constraints to M in a full-model solve instead of using this flag.

bounds : NULL, a pair c(low, high), a list of pairs or an (m·p) × 2 matrix, default = NULL
Bounds on cell values. If a single pair c(low, high) is given, it is applied to all m·p cells. Example: c(0, NA). A list of one pair or of m·p pairs (row-major; a pair may also be a list such as list(0, NULL)) is also accepted, as is a matrix or data frame with m·p rows and 2 columns.

NA, NaN, NULL (inside a list pair) and ±Inf denote an unbounded side and low = high fixes a cell; low ≤ high is required, and complex values signal a tmpinvError. The bounds are enforced exactly by CLSP (see Bounds); in the reduced model, they are mapped to the blocks.

replace_value : numeric or NULL, default = NA_real_
Replacement value for the cells of a full or block model whose bounded first step did not converge (model$status$step1 starting with "not converged"), and for the cells that violate their bounds by more than tolerance after the symmetrization. If NULL, no cell is replaced. The replaced cells are marked in result$replaced. See replace_value.

tolerance : numeric, default = sqrt(.Machine$double.eps)
Tolerance used in three places (NULL gives the default):

  • passed to CLSP: the bound and KKT tolerances of the bounded first step, the convergence of the refinement for r > 1 and the bound tolerance of the second-step verification, sqrt(tolerance)·s_u with s_u = ‖zhat‖_∞ (else ‖zhat0‖_∞);
  • the bound check of replace_value;
  • the tolerances of the stopping rule and the check of the sweeps of the reduced model.

iteration_limit : integer, default = 50
Maximum number of passes of the bounded first step (after which the CVXR fallback is used) and of iterations of the refinement loop (r > 1) in CLSP.

slack_sign : logical or NULL, default = NULL
If TRUE, the slacks of S must be ≥ 0. If NULL, TRUE if S is supplied, FALSE otherwise. Ignored in the reduced model.

cond_tolerance : numeric or NULL, default = NULL
Singular-value cutoff for the custom condition number function. If NULL, the implementation uses an internal relative cutoff of 1e-14.

m, p : integer, optional (in ...)
Accepted and ignored: the dimensions of the table are derived from b_row, b_col, i and j.

CLSP Arguments

The following arguments are passed to rclsp::clsp() (of every block fit in the reduced model); see the rclsp documentation for the details.

r : integer, default = 1
Number of refinement iterations for the pseudoinverse-based estimator (used only with model rows M). For r > 1, the misfit of the model rows is moved into residual slacks, which changes the estimator. In the reduced model with more than one block, only r = 1 is supported (an input error otherwise).

Z : numeric matrix or NULL (in ...)
A symmetric idempotent matrix (projector) defining the subspace for Bott–Duffin pseudoinversion. If NULL, the identity matrix is used, reducing the Bott–Duffin inverse to the Moore–Penrose case. With bounds, Z must be diagonal (0/1). In the reduced model, a Z would have to conform to every block, so it is of use in the full model only.

rcond : numeric, logical or NULL (in ...)
Relative cutoff on the singular values of A·Z: the singular values σ ≤ rcond·σ_max are treated as zero in both steps (model$rank, model$sv_discarded). If NULL or FALSE, the cutoff sqrt(max(dim(A))·eps) is applied, which is robust to the structural rank deficiency of AP (TM) problems (the row and the column totals both sum to the grand total); if TRUE, a cutoff equal to tolerance.

Please note that rcond is applied to the singular values of A·Z since rclsp 3.0.0 (previously to those of Z·AᵀA·Z).

final : logical or NULL, default = NULL (TRUE)
If TRUE, Step 2 (the convex correction) is solved; if FALSE, x is the Step 1 estimate.

alpha : numeric or NULL, default = NULL
Regularization parameter (weight) of Step 2, a single value in [0, 1]:

  • α = 0: Lasso (L1 norm), solved with CLARABEL
  • α = 1: Tikhonov Regularization/Ridge (L2 norm), solved with OSQP (retried with CLARABEL if needed)
  • 0 < α < 1: Elastic Net, solved with CLARABEL; its effect depends on the units of the table (e.g. thousands instead of units; see the limitations of rclsp)
    If NULL, α = 1. A vector or list of candidates, NA, NaN, Inf and values outside [0, 1] signal a clspError (the selection of α by NRMSE was removed in rclsp 3.0.0; use rclsp::cv_alpha(result$model)).

scale : logical or NULL (in ...), default = NULL (FALSE)
If TRUE, the columns of A are equilibrated in both steps (useful for totals of very different magnitudes); the minimum-norm selection is then made in the scaled variables.

... : optional
Further arguments of rclsp::clsp() (Z, rcond, scale) and CVXR arguments passed to the solver of Step 2 (e.g. solver = "CLARABEL" or solver tolerances such as eps_abs).

Value

An object of class "tmpinv", a list with the elements:

full : logical
TRUE if this result comes from the full (non-reduced) model.

model : "clsp" or list of "clsp"
A single "clsp" object in the full model, or a list of "clsp" objects for each reduced block in the reduced model (row-block by row-block; the fits of the last sweep). Each object holds the CLSP results, e.g. status, rho, residual, zhat, zhat0, rank, fixed, the condition numbers and the goodness-of-fit statistics, and can be passed to rclsp::corr(), rclsp::ttest() and rclsp::cv_alpha().

x : numeric matrix
Final estimated solution matrix of size m × p.

replaced : logical matrix
Matrix of size m × p of the cells set to replace_value (all FALSE if none).

sweeps : integer or NULL
Number of block sweeps in the reduced model (NULL in the full model).

converged : logical or NULL
Reduced model: TRUE if the sweeps met their stopping rule within sweep_limit, every block fit of the last sweep converged and no cell was replaced (NULL in the full model). The totals and the known values are not part of it (see check).

check : list or NULL
Reduced model: change, the stopping criterion of the last sweep (the largest change of a cell in units of its tolerance, times q/(1 − q) of a slow contraction; ≤ 1: settled), and residual, the largest residual of a total or known value of x in units of its tolerance (≤ 1: met; NaN if a cell was replaced); NULL in the full model (Reduced Models).

call : call
The matched call.

Methods

print(result)
Prints the call, the type of the model (with the number of blocks and sweeps of a reduced model), x, the number of replaced cells and the statuses of the fit(s).

summary(result, i = NULL)
Returns the summary of the underlying CLSP fit (an object of class "summary.clsp", printed by its print() method), where i is the (1-based) index of a reduced-block model in result$model, required in the reduced model.

Conditions

Invalid inputs signal a condition of class c("tmpinvError", "error", "condition") (?tmpinvError, the counterpart of TMPinvInputError; with the elements message and code), which can be caught with tryCatch(..., tmpinvError = function(e) ...). Invalid arguments passed to CLSP (e.g. alpha) signal a clspError of rclsp. A numerical step that does not reach its target issues an ordinary warning, and the result is still returned; the outcome is recorded in model$status (Example 6).

Warnings and Troubleshooting

Message Cause and remedy
tmpinvError: i must be a positive whole number. / j must be a positive whole number. i or j is fractional (e.g. 1.9), ≤ 0, NA, infinite, non-numeric or not a single value; it is no longer truncated.
tmpinvError: Both b_row and b_col must be provided. / Minimum length for b_row and b_col is 2. / b_row and b_col must not contain inf or NaN. Missing, too short or non-finite totals (NA included).
tmpinvError: b_row must be real, not complex. / b_row must be a numeric vector. / S must be a numeric matrix. / S must be data, not an unevaluated expression. Complex, ragged or non-numeric data (e.g. a function or an environment as S or reduced, or a list of totals that are not single numbers), an unevaluated expression (e.g. S = quote(x)), which is not run as code, or a class whose as.double() method fails (its own error was signaled before; likewise "b_val must be a numeric vector." and "M must be a numeric matrix.").
tmpinvError: b_row must be numeric, not a factor. (likewise b_col, b_val, S, M) A factor, also in a list or a data frame, which would become its level codes (factor(c("red", "blue")) gave the row totals 2, 1).
tmpinvError: b_row must be numeric, not a date or time (convert it to numbers explicitly). (likewise b_col, b_val, S, M) A Date, POSIXct, POSIXlt or difftime, also in a list, which would become its days or seconds since 1970 (or a count in the units of a difftime).
tmpinvError: b_row must be a vector (or a matrix of one row or column), got shape (…). (likewise b_col) Totals of more than one dimension: array(0, c(2, 2, 2)) was read as 8 row totals. A vector or a one-column (one-row) matrix is accepted.
tmpinvError: i and j are too large: the table would have more than 2147483647 cells. The m·p columns of the model do not fit in an R matrix (e.g. i = 1e300, which signaled an invalid length.out); a smaller table can still exceed the memory (see Limitations).
tmpinvError: Bounds length … does not match number of variables …. / bounds must be NULL, a (low, high) pair, or a sequence of (low, high) pairs. / bounds must satisfy low ≤ high. / bounds must be real, not complex. Malformed bounds: the number of pairs must be 1 or m·p, each pair must have 2 numeric (or NA/NULL) sides, low = Inf and high = -Inf are invalid. A complex side (also in a list or a data frame) signaled one of the other messages, e.g. a length mismatch for list(0, 2+7i).
tmpinvError: zero_diagonal must be TRUE, FALSE or "exact". / zero_diagonal = "exact" requires bounds that admit 0 on the diagonal. Invalid zero_diagonal (also a data frame, which signaled a coercion error), or bounds of a diagonal cell that exclude 0.
simpleError: argument 1 matches multiple formal arguments An abbreviated argument name that matches several arguments, e.g. tmpinv(b = …) for b_row, b_col and b_val. R matches the names before tmpinv() runs, so this error is R's own, not a tmpinvError; use the full names.
tmpinvError: S must have … rows. / S must be a zero-padded subset of ±I. S must have one row per total (length(b_row) + length(b_col)) and entries in {0, ±1}, at most one nonzero per row and column. An S without columns (e.g. matrix(numeric(), 4, 0), which warned in max()) is S = NULL.
tmpinvError: Both M and b_val must be defined. / M must have exactly … columns. / b_val must not contain inf or NaN. / M and b_val must have the same number of rows: … vs …. Inconsistent known values.
tmpinvError: reduced must be a pair of whole numbers (rows, columns), each ≥ 3. / Each reduced block must be at least (3, 3) …. / Grouped totals (i, j > 1) are not supported in the reduced model. / r > 1 (the residual-sign refinement) is not supported in the reduced model with more than one block; …. / M must consist of rows of the identity matrix in the reduced model. / sweep_limit must be a positive whole number. Unsupported reduced-model inputs. reduced and sweep_limit were converted with as.integer(), which truncated c(3.9, 3) and 1.9 and converted complex values, strings, dates and TRUE, while a function as sweep_limit signaled "cannot coerce type 'closure'". sweep_limit is checked in the reduced model only (it is ignored in the full model); values above .Machine$integer.max are used as .Machine$integer.max.
tmpinvError: symmetric = TRUE requires a square matrix (m == p). symmetric = TRUE for a non-square table.
tmpinvError: Reduced model: please supply the block index using i=#. / i must be in 1..n for reduced model. summary() of a reduced model without or with an invalid block index (not a single whole number in range, e.g. TRUE, "1", list(1) or a function).
clspError: alpha must be a single value in [0, 1] …. A vector or list of α, or an invalid α.
clspError: solver must be NULL or the name of a CVXR solver (a string). / tolerance must be a finite positive number. A solver that is not one string (c("OSQP", "CLARABEL") signaled "the condition has length > 1"), or an invalid tolerance, also in the reduced model (tolerance = "a" warned in as.numeric() there); tolerance = NULL is the default (it gave an NA replacement mask, and print() signaled "missing value where TRUE/FALSE needed").
Warning: User-provided S is ignored in the reduced model. S together with reduced.
Warning: Reduced model: the block sweeps did not converge in … sweeps (largest change of a cell … times its tolerance…); increase sweep_limit. The last table is returned (converged FALSE); it may not reproduce the totals. Increase sweep_limit or use larger blocks.
Warning: Reduced model: after … sweeps, a total or known value of the table is unmet by … times its tolerance, although the row and column totals agree (…); compare with the full model. Known values or bounds that conflict with the totals, or sweeps that stopped far from the fit (check). Compare with the full model (reduced = NULL), whose least-squares fit shows whether the data conflict.
Warning: Bounded least-squares active set did not converge (…); using CVXR BVLS The result is a verified bounded least-squares solution (status$step1 = "bvls fallback"); usually nothing to do.
Warning: Bounded least-squares active set did not converge (…); the last feasible estimate is kept Not a verified least-squares solution: the cells of this (block) model are set to replace_value. Try scale = TRUE, a larger iteration_limit or a larger rcond.
Warning: Step 2 failed (…); falling back to zhat The Step 1 estimate (a bounded least-squares solution) is returned; try scale = TRUE or another solver (solver = "CLARABEL").

Limitations

  • Soft totals and known values. The totals, the known values and the rows of zero_diagonal = TRUE are least-squares rows: in an inconsistent system, they are traded off against each other, although individual rows may still be met exactly (Examples 3, 4 and 6). Exact restrictions are available only as bounds (non-negativity, upper limits, fixed cells, zero_diagonal = "exact"); S with signed slacks makes a total an inequality only on its feasible side.
  • Reduced model. With r = 1, and if every block keeps the nonzero singular directions needed for its least-squares update (as with the default cutoff), the sweeps converge toward a least-squares fit of the full problem, but not necessarily the minimum-norm (Step 2) solution of the full model. The estimate therefore differs from the full-model estimate when the least-squares solution is not unique (Example 5). The convergence is linear and can be slow (several dozen sweeps of one CLSP fit per block): the stopping rule allows for a slow contraction, the extrapolation shortens it, a sweep limit reached issues a warning, and a total or known value left unmet although the totals agree issues another (check). M must select cells, r > 1 (with more than one block), S and grouped totals are not supported, and result$model holds the block fits of the last sweep only.
  • Blockwise rank cutoffs. A cutoff rcond is applied to the singular values of each block, not of the full design, so that the sweeps then fit another objective than the full model with the same cutoff, and the result depends on the partition. A 4 × 4 table with unit totals, a known unit diagonal and x ≥ 0 gave 0.6213 on the diagonal with rcond = 0.4 and reduced = c(3, 3), and a larger residual on the truncated full design than the full model; reduced = c(3, 5) recovered the identity and reduced = c(4, 4) gave 0.4130 on three diagonal cells. With the default cutoff, the identity is recovered.
  • Units. The tolerances of the sweeps scale with the cells, the totals and the known values, so that the units of the table hardly change the number of sweeps. For 0 < α < 1, the Elastic Net estimate of Step 2 depends on the units (in the full model as well), since its L1 and L2 terms scale differently.
  • Symmetrization after the fit. symmetric = TRUE averages the estimate with its transpose after the fit: asymmetric bounds can then be violated (the cells are set to replace_value, Example 7), and known cells are preserved only if their mirror cells are known with the same values.
  • Step 2 needs active bounds. Without bounds (and signed slacks), Step 2 returns the Step 1 estimate for every α.
  • Heuristic diagnostics. The t-tests, the sensitivity bands and the correlogram of rclsp are heuristic diagnostics without statistical coverage (see the rclsp documentation).
  • Dense matrices. All matrices are dense, and the number of unknowns is m·p: the canonical matrix of a full model has (m + p + k) × m·p entries, and rclsp computes its SVD and stores a (m·p) × (m·p) projector Z. A 40 × 40 table takes about 2 s in the full model (Example 5); much larger tables require the reduced model or another method. In an external stress test (peak process memory, one run each), the full model exceeded 1 GB from a 64 × 64 table on, while the reduced model completed 128 × 128 in about 200 MB.

R-Specific Differences

rtmpinv 3.1.0 follows pytmpinv 5.1.0 in its model, defaults, results, errors and warnings. The differences are:

  • Through rclsp. The Lasso (α = 0) is solved with CLARABEL, as in pytmpinv 5.1.0; a non-unique Lasso table usually agrees with the one of pytmpinv, but need not (same residual). scipy's BVLS fallback of the bounded Step 1 is replaced by a CVXR (CLARABEL) fallback, whose warnings name "CVXR BVLS" (see the R-specific differences of rclsp).
  • Conditions. Errors are conditions of class tmpinvError (TMPinvInputError in Python) or clspError; warnings are ordinary R warnings with the texts of pytmpinv's UserWarning and RuntimeWarning.
  • Result object. tmpinv() returns a list of class "tmpinv" (the attributes of TMPinvResult as elements, plus call; check is a list with the elements change and residual instead of a dict); summary(result, i) returns the summary of a CLSP fit (summarize() and display are not needed in R), and print() gives a short overview.
  • Indexing and types. Indices are 1-based (the block index i of summary(), the cells in M and bounds), but cells are stored row by row as in pytmpinv:
    • column (r − 1)·p + c of M and entry (r − 1)·p + c of bounds refer to the cell (r, c), i.e. as.vector(t(X));
    • NULL, NA/NaN and TRUE/FALSE replace None, nan and True/False; zero_diagonal = "exact" corresponds to zero_diagonal="exact", and replace_value = NULL to replace_value=None;
    • bounds are given as c(lo, hi), a list of pairs or an (m·p) × 2 matrix or data frame.
  • What matches pytmpinv. The fitted vector, ρ, the residual and the Step 2 estimate match the Python results (within numerical tolerance; for α = 0, up to the non-uniqueness of the Lasso). The Step 1 estimates of the CLSP fits (model$zhat, fixed, fixed_at) need not match coefficient by coefficient when the free columns are rank-deficient: the bounded least-squares minimizer of Step 1 is then not unique, and both implementations return one of them with the same fitted vector.
  • Random-number state. A fit leaves the session's random-number state unchanged (rclsp restores .Random.seed after every CVXR solve).
  • Arguments. r, final, alpha, slack_sign and sweep_limit are explicit arguments of tmpinv(); the other arguments of rclsp::clsp() and the CVXR solver arguments are passed through ....
    • All data and model inputs are formal arguments of tmpinv(), in the order S, M, b_row, b_col, b_val, i, j, zero_diagonal, reduced, symmetric, bounds, replace_value, tolerance, iteration_limit, r, final, alpha, cond_tolerance, slack_sign, sweep_limit.
    • pytmpinv's tmpinv() has only bounds, replace_value, tolerance, iteration_limit and cond_tolerance as parameters and takes the other inputs as keyword arguments, so positional calls differ.
    • pytmpinv's TMPinvSolve() is not exported.
  • Validation. The following checks are as in pytmpinv 5.1.0; in addition, rtmpinv uses a sweep_limit above .Machine$integer.max as .Machine$integer.max.
    • i and j must be positive whole numbers (a tmpinvError "i must be a positive whole number.").
    • zero_diagonal must be TRUE, FALSE (a single non-missing logical or number) or "exact" (otherwise a tmpinvError).
    • The block index of summary() must be whole.
    • reduced must be a pair of whole numbers, each ≥ 3, and sweep_limit (in the reduced model) a positive whole number.
    • bounds must be real: a complex side signals "bounds must be real, not complex." (pytmpinv: a NumPy complex scalar was made real; in rtmpinv, it signaled a less specific tmpinvError).

A cross-check of rtmpinv 3.0.0 against pytmpinv 5.0.0 on 40 random tables (25 full and 15 reduced models) gave the same statuses, the same numbers of sweeps in all reduced models and the same replaced cells. The tables covered non-negativity and cell-specific bounds with NaN sides and fixed cells, known cells including repeated ones, zero_diagonal = TRUE and "exact", symmetric = TRUE, inequality totals with S, consistent and inconsistent totals and α ∈ {0.5, 1}. The maximum absolute differences were 6·10⁻¹⁴ for the tables x (5·10⁻¹⁴ in the reduced models) and 6·10⁻¹⁵ for ρ and the residuals.

For 3.1.0, a cross-check against pytmpinv 5.1.0 on 24 random reduced models (5 to 9 rows and columns, cells of scales 10⁻² to 10³, 0 to 7 known cells, with and without x ≥ 0, consistent and inconsistent totals, exact and noisy known values) gave the same converged, no warnings in either and the same numbers of sweeps in 23 models (74 vs. 73 at the stopping threshold in the other); the tables agreed to 9·10⁻¹³ of their largest cell. The 4 × 4 table diag(10⁸, 1, 1, 1) of Reduced Models and the table of Example 5 take the same 27 and 22 sweeps in both, and sweep_limit = 26 gives the same warning.

What's New in 3.1.0

Version 3.1.0 implements the changes of pytmpinv 5.1.0 (the per-cell stopping rule of the reduced model) and requires rclsp 3.1.0; the full list of changes is in NEWS.md.

  • Reduced model: the sweeps stop when the change of every cell is at most tolerance times its own scale (the larger of |x_ij| and the terms |b_k| + Σ |x| of its smallest row, column or known value) plus a rounding floor 30·eps·max(‖b‖₂, max |x|), and, while they contract steadily by a factor q (0.5 ≤ q < 1), when the change times q/(1 − q) is; such a contraction is extrapolated along the last sweep (clipped to the bounds, undone if the next sweep moves the table more). The previous rule, tolerance · max |x|, stopped small cells next to large ones far from the fit, 'converged' and without a warning. Example 5 now takes 22 sweeps instead of 35 (known values met to 6.0·10⁻¹⁰ instead of 1.1·10⁻⁷). Found in an external review.
  • Reduced model: when the sweeps stop, every total and known value is checked against its tolerance; a warning is issued if one is unmet while the row and column totals agree. Totals that disagree are fitted by least squares, as in the full model, without a warning.
  • New result elements converged and check (reduced model; NULL in the full model); the warning at sweep_limit reports the largest change of a cell in units of its tolerance.
  • A complex side of bounds signals "bounds must be real, not complex.".
  • Requires rclsp ≥ 3.1.0 (componentwise tolerances, connected blocks, range-safe norms).
  • Documentation: the Lasso table (α = 0) of Example 4 is one of many tables with the same, smallest L1 distance to the anchor.

What's New in 3.0.1

Version 3.0.1 fixes the defects found in an external review of version 3.0.0 (as pytmpinv 5.0.1); the full list of changes is in NEWS.md.

  • Reduced model: r > 1 with more than one block raises an error. Every block fit built its residual slacks from its own model rows given the other blocks, so that the sweeps did not minimize a common objective: a 4 × 4 table with unit totals, a known unit diagonal and x ≥ 0, whose only solution is the identity, gave 0.625 on the diagonal with every block 'optimal'. With one block, r > 1 is kept (the result equals the full model). Found in an external review.
  • Reduced model: the sweeps stop when the largest change of a cell is below tolerance·max|x| (tolerance for a zero table) instead of tolerance·max(1, max|x|), which stopped a table in units of 10⁻⁹ after one sweep (a row error of 1.875 after the conversion back). Found in an external review.
    • The threshold scales with the magnitude of the table, which fixes the premature stop in small units.
    • The number of sweeps can still change with the units; for 0 < α < 1, the Elastic Net estimate of Step 2 depends on the units, in the full model as well, since its L1 and L2 terms scale differently.
  • A 3-D array M raises an error ("M must be a numeric matrix.") instead of being flattened into one column. Found in an external review.
  • Requires rclsp ≥ 3.0.1 (the bound tolerance of the first step).
  • Documentation: the reduced model converges toward a least-squares fit of the full problem with r = 1 if every block keeps the nonzero singular directions needed for its least-squares update (rcond is applied to each block separately); fixed is the final working set of the first step.

What's New in 3.0.0

Version 3.0.0 adapts rtmpinv to rclsp 3.0.0 and implements the methodology of pytmpinv 5.0.0; the full list of changes is in NEWS.md.

  • Bounds are passed to CLSP and enforced exactly (bounded-variable least squares in Step 1, constraints in Step 2); the iterative heuristic of 2.0.0 (freezing in-bound cells as known values and replacing out-of-bound cells) is removed.
  • replace_value applies only to the cells of non-converged fits and to bound violations caused by the symmetrization; NULL keeps the estimate; new element replaced.
  • zero_diagonal = "exact" (exact zeros via bounds); zero_diagonal = TRUE adds soft model rows as before, now without dropping the row x_kk = 0 of a known diagonal cell (the reduced model accepts repeated cells in M).
  • S uses signed slacks (slack_sign = TRUE by default), so that S_kk = ±1 makes a total a "≤"/"≥" condition on its feasible side.
  • The reduced model solves the full problem by block-coordinate sweeps (new argument sweep_limit, new element sweeps): the assembled table converges toward a least-squares fit of the full model (it reproduces consistent totals and known values), instead of fitting each block independently with one slack per total.
  • All arguments of rclsp::clsp() are passed through (r, Z, rcond, final, alpha, scale, slack_sign, solver arguments); α is a single value in [0, 1] (α = 1 by default).
  • Bounds given as NA, NaN or ±Inf denote unbounded sides and matrices of pairs are accepted; malformed bounds signal a tmpinvError; a test suite ported from pytmpinv.

Breaking changes (see NEWS.md):

  • rclsp ≥ 3.0.0 (and hence CVXR ≥ 1.9.3) is required;
  • the estimates with bounds differ from 2.0.0 (exact bounded least squares instead of the heuristic);
  • replace_value has a new meaning, and NULL keeps the estimate;
  • vectors of alpha and the NRMSE rule for alpha = NULL (rclsp) are removed;
  • S is validated against the number of totals and uses signed slacks;
  • the reduced model is estimated by block sweeps (different estimates, no block slacks) and rejects grouped totals;
  • errors are tmpinvError conditions.

Citing

If you use TMPinv in your work, please cite the method:

Bolotov, I. (2025). CLSP: Linear Algebra Foundations of a Modular Two-Step Convex Optimization-Based Estimator for Ill-Posed Problems. Mathematics, 13(21), 3476. https://doi.org/10.3390/math13213476

and the version of the package you used (packageVersion("rtmpinv"), citation("rtmpinv")):

rtmpinv, version 3.1.0: Tabular Matrix Problems via Pseudoinverse Estimation [R package]. https://github.com/econcz/rtmpinv

@article{bolotov2025clsp,
  author  = {Bolotov, I.},
  title   = {{CLSP}: Linear Algebra Foundations of a Modular Two-Step Convex
             Optimization-Based Estimator for Ill-Posed Problems},
  journal = {Mathematics},
  year    = {2025},
  volume  = {13},
  number  = {21},
  pages   = {3476},
  doi     = {10.3390/math13213476}
}

@manual{rtmpinv,
  title   = {rtmpinv: Tabular Matrix Problems via Pseudoinverse Estimation},
  note    = {R package version 3.1.0},
  url     = {https://github.com/econcz/rtmpinv}
}

Acknowledgements

The preparation of versions 3.0.0, 3.0.1 and 3.1.0 — code changes, tests and documentation — was assisted by Claude (Anthropic), an AI assistant.

Bibliography

Bolotov, I. (2025). CLSP: Linear Algebra Foundations of a Modular Two-Step Convex Optimization-Based Estimator for Ill-Posed Problems. Mathematics, 13(21), 3476. https://doi.org/10.3390/math13213476

License

MIT License — see the LICENSE file.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("rtmpinv")

3.1.0 by Ilya Bolotov, 6 hours ago


https://github.com/econcz/rtmpinv


Report a bug at https://github.com/econcz/rtmpinv/issues


Browse source code at https://github.com/cran/rtmpinv


Authors: Ilya Bolotov [aut, cre] (ORCID:


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports rclsp

Suggests testthat


Imported by rtmpinvi.


See at CRAN