diff options
author | Alberto Ruiz <aruiz@um.es> | 2015-05-24 12:45:23 +0200 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2015-05-24 12:45:23 +0200 |
commit | 8ede2ed162f3d00172ee3fa4835e3ee2184bcd99 (patch) | |
tree | cdb3025dc5e469603d32d4e200cc753d3502c6d8 /packages/base/src/C | |
parent | b1b445697db31b1603a31747ca31151f97ee7263 (diff) |
joint extractor of rows and columns
Diffstat (limited to 'packages/base/src/C')
-rw-r--r-- | packages/base/src/C/lapack-aux.c | 88 |
1 files changed, 33 insertions, 55 deletions
diff --git a/packages/base/src/C/lapack-aux.c b/packages/base/src/C/lapack-aux.c index e76d31e..c2cdc62 100644 --- a/packages/base/src/C/lapack-aux.c +++ b/packages/base/src/C/lapack-aux.c | |||
@@ -1290,19 +1290,18 @@ int multiplyQ(int ta, int tb, KQMAT(a),KQMAT(b),QMAT(r)) { | |||
1290 | int multiplyI(int ta, int tb, KIMAT(a), KIMAT(b), IMAT(r)) { | 1290 | int multiplyI(int ta, int tb, KIMAT(a), KIMAT(b), IMAT(r)) { |
1291 | int i,j,k; | 1291 | int i,j,k; |
1292 | int n; | 1292 | int n; |
1293 | int u, v; | 1293 | int ai,ak,bk,bj; |
1294 | if (ta==0) { | 1294 | |
1295 | n = ac; | 1295 | n = ta ? ar : ac; |
1296 | } else { | 1296 | |
1297 | n = ar; | 1297 | if (ta==0) { ai = 1; ak = ar; } else { ai = ar; ak = 1; } |
1298 | } | 1298 | if (tb==0) { bk = 1; bj = br; } else { bk = br; bj = 1; } |
1299 | |||
1299 | for (i=0;i<rr;i++) { | 1300 | for (i=0;i<rr;i++) { |
1300 | for (j=0;j<rc;j++) { | 1301 | for (j=0;j<rc;j++) { |
1301 | rp[i*rc+j] = 0; | 1302 | rp[i+rr*j] = 0; |
1302 | for (k=0; k<n; k++) { | 1303 | for (k=0; k<n; k++) { |
1303 | u = ta==0 ? ap[i*ac+k] : ap[k*ac+i]; | 1304 | rp[i+rr*j] += ap[ai*i+ak*k] * bp[bk*k+bj*j]; |
1304 | v = tb==0 ? bp[k*bc+j] : bp[j*bc+k]; | ||
1305 | rp[i*rc+j] += u*v; | ||
1306 | } | 1305 | } |
1307 | } | 1306 | } |
1308 | } | 1307 | } |
@@ -1622,65 +1621,44 @@ int chooseD(KIVEC(cond),KDVEC(lt),KDVEC(eq),KDVEC(gt),DVEC(r)) { | |||
1622 | 1621 | ||
1623 | //////////////////////// extract ///////////////////////////////// | 1622 | //////////////////////// extract ///////////////////////////////// |
1624 | 1623 | ||
1625 | #define EXTRACT_IMP \ | 1624 | #define EXTRACT_IMP \ |
1626 | /*REQUIRES((tm == 0 && jn==rr && mc==rc) || (jn==rr && mr==rc) ,BAD_SIZE); */ \ | 1625 | int i,j,si,sj,ni,nj,ai,aj; \ |
1627 | DEBUGMSG("extractRD") \ | 1626 | if (tm==0) { \ |
1628 | int k,i,s; \ | 1627 | ai=mc; aj=1; \ |
1629 | if (tm==0) { \ | 1628 | } else { \ |
1630 | if (mode==0) { \ | 1629 | ai=1, aj=mc; \ |
1631 | for (k=0; k<jp[1]-jp[0]+1; k++) { \ | 1630 | } \ |
1632 | s = k + jp[0]; \ | 1631 | ni = modei ? in : ip[1]-ip[0]+1; \ |
1633 | printf("%d\n",s); \ | 1632 | nj = modej ? jn : jp[1]-jp[0]+1; \ |
1634 | for (i=0; i<mc; i++) { \ | 1633 | \ |
1635 | rp[rc*k+i] = mp[mc*s+i]; \ | 1634 | for (i=0; i<ni; i++) { \ |
1636 | } \ | 1635 | si = modei ? ip[i] : i+ip[0]; \ |
1637 | } \ | 1636 | \ |
1638 | } else { \ | 1637 | for (j=0; j<nj; j++) { \ |
1639 | for (k=0;k<jn;k++) { \ | 1638 | sj = modej ? jp[j] : j+jp[0]; \ |
1640 | s = jp[k]; \ | 1639 | \ |
1641 | for (i=0; i<mc; i++) { \ | 1640 | rp[rc*i+j] = mp[ai*si+aj*sj]; \ |
1642 | rp[rc*k+i] = mp[mc*s+i]; \ | 1641 | } \ |
1643 | } \ | 1642 | } \ |
1644 | } \ | ||
1645 | } \ | ||
1646 | } else { \ | ||
1647 | if (mode==0) { \ | ||
1648 | for (k=0; k<jp[1]-jp[0]+1; k++) { \ | ||
1649 | s = k + jp[0]; \ | ||
1650 | printf("%d\n",s); \ | ||
1651 | for (i=0; i<mr; i++) { \ | ||
1652 | rp[rc*k+i] = mp[mc*i+s]; \ | ||
1653 | } \ | ||
1654 | } \ | ||
1655 | } else { \ | ||
1656 | for (k=0;k<jn;k++) { \ | ||
1657 | s = jp[k]; \ | ||
1658 | for (i=0; i<mr; i++) { \ | ||
1659 | rp[rc*k+i] = mp[mc*i+s]; \ | ||
1660 | } \ | ||
1661 | } \ | ||
1662 | } \ | ||
1663 | } \ | ||
1664 | OK | 1643 | OK |
1665 | 1644 | ||
1666 | 1645 | int extractD(int modei, int modej, int tm, KIVEC(i), KIVEC(j), KDMAT(m), DMAT(r)) { | |
1667 | int extractRD(int mode, int tm, KIVEC(j), KDMAT(m), DMAT(r)) { | ||
1668 | EXTRACT_IMP | 1646 | EXTRACT_IMP |
1669 | } | 1647 | } |
1670 | 1648 | ||
1671 | int extractRF(int mode, int tm, KIVEC(j), KFMAT(m), FMAT(r)) { | 1649 | int extractF(int modei, int modej, int tm, KIVEC(i), KIVEC(j), KFMAT(m), FMAT(r)) { |
1672 | EXTRACT_IMP | 1650 | EXTRACT_IMP |
1673 | } | 1651 | } |
1674 | 1652 | ||
1675 | int extractRC(int mode, int tm, KIVEC(j), KCMAT(m), CMAT(r)) { | 1653 | int extractC(int modei, int modej, int tm, KIVEC(i), KIVEC(j), KCMAT(m), CMAT(r)) { |
1676 | EXTRACT_IMP | 1654 | EXTRACT_IMP |
1677 | } | 1655 | } |
1678 | 1656 | ||
1679 | int extractRQ(int mode, int tm, KIVEC(j), KQMAT(m), QMAT(r)) { | 1657 | int extractQ(int modei, int modej, int tm, KIVEC(i), KIVEC(j), KQMAT(m), QMAT(r)) { |
1680 | EXTRACT_IMP | 1658 | EXTRACT_IMP |
1681 | } | 1659 | } |
1682 | 1660 | ||
1683 | int extractRI(int mode, int tm, KIVEC(j), KIMAT(m), IMAT(r)) { | 1661 | int extractI(int modei, int modej, int tm, KIVEC(i), KIVEC(j), KIMAT(m), IMAT(r)) { |
1684 | EXTRACT_IMP | 1662 | EXTRACT_IMP |
1685 | } | 1663 | } |
1686 | 1664 | ||