C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 3rd, 2012, 06:30 AM
maasha maasha is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 1 maasha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m 29 sec
Reputation Power: 0
Memory & arrays - Vector update problem

I am trying some dynamic programming. However this vector update does not work since I see bad values for mis, ins and del. I suspect that some values are overwritten by accident because multiple variable point to the same memory?

Code:
      void vector_update(score *vec, char *seq, char *pat, unsigned int pat_len, unsigned int pos)
      {
        score diag = vec[0];
        score up   = {0, 0, 0, 0, 0};   // insertion
        score left = vec[1];            // deletion
        score new  = {0, 0, 0, 0, 0};

        unsigned int i = 0;

        for (i = 0; i < pat_len; i++)
        {
          if (MATCH(seq[pos], pat[i]))                        // match
          {
            new = diag;
            new.match++;
          }
          else
          {
            if (left.ed <= diag.ed && left.ed <= up.ed)       // deletion
            {
              new = left;
              new.del++;
            }
            else if (diag.ed <= up.ed && diag.ed <= left.ed)   // mismatch
            {
              new = diag;
              new.mis++;
            }
            else if (up.ed <= diag.ed && up.ed <= left.ed)      // insertion
            {
              new = up;
              new.ins++;
            }

            new.ed++;
          }

          diag = vec[i + 1];
          up   = new;
          left = vec[i + 2];

          vec[i + 1] = new;
        }
      }

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Memory & arrays - Vector update problem


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap