<p dir="auto">I am trying to do least squares with a rank deficient matrix using  <a href="http://docs.julialang.org/en/release-0.4/stdlib/linalg/" rel="nofollow">the / operator</a>. It works in the general case, but fails when applied on a square symmetric matrix with duplicate rows (and columns).</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt; n, p = 99, 8;
&gt; y = randn(n);
&gt; X = randn(n, p);
&gt; X[:, 1] = 1;

# Rank deficient. X[:, 1] = X[:, 2] + X[:, 3] 
&gt; X[:, 3] = 1 - X[:, 2];
&gt; (X\y)'
1x8 Array{Float64,2}:
 -0.0643163  -0.123173  0.0588565  0.0812868  -0.0363878  -0.0676099  -0.0715549  0.0175931
&gt; ((X'*X)\(X'*y))'
1x8 Array{Float64,2}:
 -0.124538  -0.0629509  0.119078  0.0812868  -0.0363878  -0.0676099  -0.0715549  0.0175931

# Duplicate column. X[:, 1] = X[:, 3] = 1
&gt; X[:, 3] = 1;
&gt; (X\y)'
1x8 Array{Float64,2}:
 -0.00272991  -0.182029  -0.00272991  0.0812868  -0.0363878  -0.0676099  -0.0715549  0.0175931
&gt; (X'*X)\(X'*y)
ERROR: Base.LinAlg.SingularException(8)
 in \ at linalg/factorization.jl:25
 in \ at linalg/dense.jl:448"><pre class="notranslate"><span class="pl-k">&gt;</span> n, p <span class="pl-k">=</span> <span class="pl-c1">99</span>, <span class="pl-c1">8</span>;
<span class="pl-k">&gt;</span> y <span class="pl-k">=</span> <span class="pl-c1">randn</span>(n);
<span class="pl-k">&gt;</span> X <span class="pl-k">=</span> <span class="pl-c1">randn</span>(n, p);
<span class="pl-k">&gt;</span> X[:, <span class="pl-c1">1</span>] <span class="pl-k">=</span> <span class="pl-c1">1</span>;

<span class="pl-c"><span class="pl-c">#</span> Rank deficient. X[:, 1] = X[:, 2] + X[:, 3] </span>
<span class="pl-k">&gt;</span> X[:, <span class="pl-c1">3</span>] <span class="pl-k">=</span> <span class="pl-c1">1</span> <span class="pl-k">-</span> X[:, <span class="pl-c1">2</span>];
<span class="pl-k">&gt;</span> (X<span class="pl-k">\</span>y)<span class="pl-k">'</span>
<span class="pl-c1">1</span>x8 Array{Float64,<span class="pl-c1">2</span>}<span class="pl-k">:</span>
 <span class="pl-k">-</span><span class="pl-c1">0.0643163</span>  <span class="pl-k">-</span><span class="pl-c1">0.123173</span>  <span class="pl-c1">0.0588565</span>  <span class="pl-c1">0.0812868</span>  <span class="pl-k">-</span><span class="pl-c1">0.0363878</span>  <span class="pl-k">-</span><span class="pl-c1">0.0676099</span>  <span class="pl-k">-</span><span class="pl-c1">0.0715549</span>  <span class="pl-c1">0.0175931</span>
<span class="pl-k">&gt;</span> ((X<span class="pl-k">'</span><span class="pl-k">*</span>X)<span class="pl-k">\</span>(X<span class="pl-k">'</span><span class="pl-k">*</span>y))<span class="pl-k">'</span>
<span class="pl-c1">1</span>x8 Array{Float64,<span class="pl-c1">2</span>}<span class="pl-k">:</span>
 <span class="pl-k">-</span><span class="pl-c1">0.124538</span>  <span class="pl-k">-</span><span class="pl-c1">0.0629509</span>  <span class="pl-c1">0.119078</span>  <span class="pl-c1">0.0812868</span>  <span class="pl-k">-</span><span class="pl-c1">0.0363878</span>  <span class="pl-k">-</span><span class="pl-c1">0.0676099</span>  <span class="pl-k">-</span><span class="pl-c1">0.0715549</span>  <span class="pl-c1">0.0175931</span>

<span class="pl-c"><span class="pl-c">#</span> Duplicate column. X[:, 1] = X[:, 3] = 1</span>
<span class="pl-k">&gt;</span> X[:, <span class="pl-c1">3</span>] <span class="pl-k">=</span> <span class="pl-c1">1</span>;
<span class="pl-k">&gt;</span> (X<span class="pl-k">\</span>y)<span class="pl-k">'</span>
<span class="pl-c1">1</span>x8 Array{Float64,<span class="pl-c1">2</span>}<span class="pl-k">:</span>
 <span class="pl-k">-</span><span class="pl-c1">0.00272991</span>  <span class="pl-k">-</span><span class="pl-c1">0.182029</span>  <span class="pl-k">-</span><span class="pl-c1">0.00272991</span>  <span class="pl-c1">0.0812868</span>  <span class="pl-k">-</span><span class="pl-c1">0.0363878</span>  <span class="pl-k">-</span><span class="pl-c1">0.0676099</span>  <span class="pl-k">-</span><span class="pl-c1">0.0715549</span>  <span class="pl-c1">0.0175931</span>
<span class="pl-k">&gt;</span> (X<span class="pl-k">'</span><span class="pl-k">*</span>X)<span class="pl-k">\</span>(X<span class="pl-k">'</span><span class="pl-k">*</span>y)
ERROR<span class="pl-k">:</span> Base<span class="pl-k">.</span>LinAlg<span class="pl-k">.</span><span class="pl-c1">SingularException</span>(<span class="pl-c1">8</span>)
 <span class="pl-k">in</span> <span class="pl-k">\</span> at linalg<span class="pl-k">/</span>factorization<span class="pl-k">.</span>jl<span class="pl-k">:</span><span class="pl-c1">25</span>
 <span class="pl-k">in</span> <span class="pl-k">\</span> at linalg<span class="pl-k">/</span>dense<span class="pl-k">.</span>jl<span class="pl-k">:</span><span class="pl-c1">448</span></pre></div>
<p dir="auto">I propose adding methods for <code class="notranslate">all</code> and <code class="notranslate">any</code> to allow for convenient testing of nary predicates. The behavior would be equivalent to that given by</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="myall(f,itrs...) = all(map(args-&gt;f(args...),zip(itrs...)))"><pre class="notranslate"><span class="pl-en">myall</span>(f,itrs<span class="pl-k">...</span>) <span class="pl-k">=</span> <span class="pl-c1">all</span>(<span class="pl-c1">map</span>(args<span class="pl-k">-&gt;</span><span class="pl-c1">f</span>(args<span class="pl-k">...</span>),<span class="pl-c1">zip</span>(itrs<span class="pl-k">...</span>)))</pre></div>
<p dir="auto">but with an efficient implementation along the lines of the current <code class="notranslate">all(f,itr)</code> method (same thing for <code class="notranslate">any</code>). This additional signature is directly analogous to the extant generalization for <code class="notranslate">map</code> methods and allows for things like</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; xs,Xs = 1:3,[Set([1,2]),Set([2,5]),Set([3])]
julia&gt; myall(in,xs,Xs)
true"><pre class="notranslate">julia<span class="pl-k">&gt;</span> xs,Xs <span class="pl-k">=</span> <span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">3</span>,[<span class="pl-c1">Set</span>([<span class="pl-c1">1</span>,<span class="pl-c1">2</span>]),<span class="pl-c1">Set</span>([<span class="pl-c1">2</span>,<span class="pl-c1">5</span>]),<span class="pl-c1">Set</span>([<span class="pl-c1">3</span>])]
julia<span class="pl-k">&gt;</span> <span class="pl-c1">myall</span>(in,xs,Xs)
<span class="pl-c1">true</span></pre></div>
<p dir="auto">which saves one from having to zip and splat for nary functions.</p>