Computes Moran's I along with expected value and standard deviation under the null hypothesis. Optimized with Armadillo vectorization.
moranI_full_cpp(expr_matrix, W)List containing observed I, expected I, and standard deviation
Numeric matrix (genes x spots)
Spatial weights matrix (spots x spots), row-standardized
This function pre-computes all weight matrix statistics once, then loops over genes efficiently. The main bottleneck is the z * W * z' computation which is O(n^2) per gene.