@@ -1541,38 +1541,8 @@ function factorize(A::AbstractMatrix{T}) where T
15411541    m, n =  size (A)
15421542    if  m ==  n
15431543        if  m ==  1  return  A[1 ] end 
1544-         utri    =  true 
1545-         utri1   =  true 
1546-         herm    =  true 
1547-         sym     =  true 
1548-         for  j =  1 : n- 1 , i =  j+ 1 : m
1549-             if  utri1
1550-                 if  A[i,j] !=  0 
1551-                     utri1 =  i ==  j +  1 
1552-                     utri =  false 
1553-                 end 
1554-             end 
1555-             if  sym
1556-                 sym &=  A[i,j] ==  A[j,i]
1557-             end 
1558-             if  herm
1559-                 herm &=  A[i,j] ==  conj (A[j,i])
1560-             end 
1561-             if  ! (utri1| herm| sym) break  end 
1562-         end 
1563-         ltri =  true 
1564-         ltri1 =  true 
1565-         for  j =  3 : n, i =  1 : j- 2 
1566-             ltri1 &=  A[i,j] ==  0 
1567-             if  ! ltri1 break  end 
1568-         end 
1544+         utri, utri1, ltri, ltri1, sym, herm =  getstructure (A)
15691545        if  ltri1
1570-             for  i =  1 : n- 1 
1571-                 if  A[i,i+ 1 ] !=  0 
1572-                     ltri &=  false 
1573-                     break 
1574-                 end 
1575-             end 
15761546            if  ltri
15771547                if  utri
15781548                    return  Diagonal (A)
@@ -1610,6 +1580,54 @@ factorize(A::Adjoint)   =   adjoint(factorize(parent(A)))
16101580factorize (A:: Transpose ) =  transpose (factorize (parent (A)))
16111581factorize (a:: Number )    =  a #  same as how factorize behaves on Diagonal types
16121582
1583+ function  getstructure (A:: StridedMatrix )
1584+     m, n =  size (A)
1585+     if  m ==  1  return  A[1 ] end 
1586+     utri    =  true 
1587+     utri1   =  true 
1588+     herm    =  true 
1589+     sym     =  true 
1590+     for  j =  1 : n- 1 , i =  j+ 1 : m
1591+         if  utri1
1592+             if  A[i,j] !=  0 
1593+                 utri1 =  i ==  j +  1 
1594+                 utri =  false 
1595+             end 
1596+         end 
1597+         if  sym
1598+             sym &=  A[i,j] ==  A[j,i]
1599+         end 
1600+         if  herm
1601+             herm &=  A[i,j] ==  conj (A[j,i])
1602+         end 
1603+         if  ! (utri1| herm| sym) break  end 
1604+     end 
1605+     ltri =  true 
1606+     ltri1 =  true 
1607+     for  j =  3 : n, i =  1 : j- 2 
1608+         ltri1 &=  A[i,j] ==  0 
1609+         if  ! ltri1 break  end 
1610+     end 
1611+     if  ltri1
1612+         for  i =  1 : n- 1 
1613+             if  A[i,i+ 1 ] !=  0 
1614+                 ltri &=  false 
1615+                 break 
1616+             end 
1617+         end 
1618+     end 
1619+     return  (utri, utri1, ltri, ltri1, sym, herm)
1620+ end 
1621+ function  getstructure (A:: AbstractMatrix )
1622+     utri =  istriu (A)
1623+     utri1 =  istriu (A,- 1 )
1624+     ltri =  istril (A)
1625+     ltri1 =  istril (A,1 )
1626+     sym =  issymmetric (A)
1627+     herm =  ishermitian (A)
1628+     return  (utri, utri1, ltri, ltri1, sym, herm)
1629+ end 
1630+ 
16131631# # Moore-Penrose pseudoinverse
16141632
16151633""" 
0 commit comments