~ubuntu-branches/ubuntu/oneiric/kalgebra/oneiric-updates

« back to all changes in this revision

Viewing changes to analitza/analyzer.cpp

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman, Jonathan Kolberg, Scott Kitterman
  • Date: 2011-09-08 09:54:16 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: package-import@ubuntu.com-20110908095416-56n1ezw5lvr54p45
Tags: 4:4.7.1-0ubuntu1
[ Jonathan Kolberg ]
* New upstream release

[ Scott Kitterman ]
* Make the mobile package descriptions not identical to the regular ones
* Improve kalgebra-dbg long descriptions
* Fix kalgebra-dbg depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
1515
1515
                                        imono.first = sc->value();
1516
1516
                                        imono.second = cx->m_params[var];
1517
1517
                                        
 
1518
                                        cx->m_params[var]=0;
 
1519
                                        delete cx;
 
1520
                                        
1518
1521
                                        ismono=true;
1519
1522
                                }
1520
1523
                        } else if(mult==Operator::times) {
1521
1524
                                imono.first=1;
1522
1525
                                Apply::iterator it=cx->firstValue(), itEnd=cx->end();
1523
1526
                                QList<Object*> vars;
 
1527
                                QList<Object*> values;
1524
1528
                                
1525
1529
                                for(; it!=itEnd; ++it) {
1526
1530
                                        if((*it)->type()==Object::value) {
1527
1531
                                                imono.first *= static_cast<Cn*>(*it)->value();
 
1532
                                                values += *it;
1528
1533
                                                ismono=true;
1529
1534
                                        } else {
1530
1535
                                                vars += *it;
1534
1539
                                if(ismono) {
1535
1540
                                        cx->m_params = vars;
1536
1541
                                        imono.second = cx;
 
1542
                                        qDeleteAll(values);
1537
1543
                                }
1538
1544
                        }
1539
1545
                } else if(cx->firstOperator()==Operator::minus && cx->isUnary()) {
1540
1546
                        imono = constructMonomial(o, *cx->firstValue(), sign);
 
1547
                        *cx->firstValue()=0;
 
1548
                        delete cx;
1541
1549
                        ismono=true;
1542
1550
                                
1543
1551
                        if(o==Operator::times)
1565
1573
        Operator o(c->firstOperator());
1566
1574
        bool sign=true, first=true;
1567
1575
        
1568
 
        for(Apply::const_iterator it=c->m_params.constBegin(), itEnd=c->constEnd(); it!=itEnd; ++it) {
 
1576
        for(Apply::const_iterator it=c->firstValue(), itEnd=c->constEnd(); it!=itEnd; ++it, first=false) {
1569
1577
                Monomial imono = constructMonomial(o, *it, sign);
1570
1578
                
1571
1579
                if(o==Operator::minus && !first)
1583
1591
//              qDebug() << "->" << c->toString() << c->firstOperator().toString() << found;
1584
1592
                if(found) {
1585
1593
                        it1->first += imono.first;
 
1594
                        delete imono.second;
1586
1595
                        
1587
1596
                        if(it1->first==0.) {
1588
1597
                                delete it1->second;
1589
1598
                                monos.erase(it1);
1590
1599
                        }
1591
1600
                } else {
1592
 
                        imono.second = imono.second->copy();
1593
1601
                        monos.append(imono);
1594
1602
                }
1595
 
                first=false;
1596
1603
        }
 
1604
        c->m_params.clear();
1597
1605
        
1598
1606
        delete c;
1599
1607
        c=0;
1602
1610
        if(monos.count()==1) {
1603
1611
                root=createMono(o, monos.first());
1604
1612
        } else if(monos.count()>1) {
1605
 
                c= new Apply;
 
1613
                Apply* c= new Apply;
1606
1614
                c->appendBranch(new Operator(o));
1607
1615
                
1608
1616
                QList<Monomial>::iterator i=monos.begin();
1614
1622
                        
1615
1623
                        if(toAdd)
1616
1624
                                c->appendBranch(toAdd);
 
1625
                        
1617
1626
                        first=false;
1618
1627
                }
1619
1628
                root=c;
1624
1633
                cn->appendBranch(new Operator(Operator::minus));
1625
1634
                cn->appendBranch(root);
1626
1635
                root=cn;
1627
 
        }
1628
 
        
1629
 
        if(!root) {
1630
 
                delete c;
 
1636
        } else if(!root) {
1631
1637
                root=new Cn(0.);
1632
1638
        }
1633
1639