diff --git a/db/de1/lcs_8c.html b/db/de1/lcs_8c.html index 6c29819d..e7757245 100644 --- a/db/de1/lcs_8c.html +++ b/db/de1/lcs_8c.html @@ -128,10 +128,10 @@ Enumerations

Functions

void lcslen (const char *s1, const char *s2, int l1, int l2, int **L, int **B) - @breif Computes LCS between s1 and s2 using a dynamic-programming approach
+ Computes LCS between s1 and s2 using a dynamic-programming approach.
  char * lcsbuild (const char *s1, int l1, int l2, int **L, int **B) - @breif Builds the LCS according to B using a traceback approach
+ Builds the LCS according to B using a traceback approach.
  static void test ()  Self-test implementations.
@@ -155,7 +155,7 @@ Functions
-
15{LEFT, UP, DIAG};
+
18{LEFT, UP, DIAG};
@@ -204,45 +204,49 @@ Functions
-

@breif Builds the LCS according to B using a traceback approach

+

Builds the LCS according to B using a traceback approach.

Parameters
- - - - - + + + + +
1s1 first null-terminated string
2l1 length of s1
3l2 length of s2
4L matrix of size l1 x l2
5B matrix of size l1 x l2
s1first null-terminated string
l1length of s1
l2length of s2
Lmatrix of size l1 x l2
Bmatrix of size l1 x l2
Returns
lcs longest common subsequence
-
59 {
-
60 int i, j, lcsl;
-
61 char *lcs;
-
62 lcsl = L[l1][l2];
-
63
-
64 /* my lcs is at least the empty symbol */
-
65 lcs = (char *)calloc(lcsl+1, sizeof(char)); /* null-terminated \0 */
-
66 if (!lcs) {
-
67 perror("calloc: ");
-
68 return NULL;
-
69 }
-
70
-
71 i = l1, j = l2;
-
72 while (i > 0 && j > 0) {
-
73 /* walk the matrix backwards */
-
74 if (B[i][j] == DIAG) {
-
75 lcs[--lcsl] = s1[i-1];
-
76 i = i - 1;
-
77 j = j - 1;
-
78 }
-
79 else if (B[i][j] == LEFT)
-
80 j = j - 1;
-
81 else
-
82 i = i - 1;
-
83 }
-
84 return lcs;
-
85}
+
64 {
+
65 int i, j, lcsl;
+
66 char *lcs;
+
67 lcsl = L[l1][l2];
+
68
+
69 /* my lcs is at least the empty symbol */
+
70 lcs = (char *)calloc(lcsl+1, sizeof(char)); /* null-terminated \0 */
+
71 if (!lcs) {
+
72 perror("calloc: ");
+
73 return NULL;
+
74 }
+
75
+
76 i = l1, j = l2;
+
77 while (i > 0 && j > 0) {
+
78 /* walk the matrix backwards */
+
79 if (B[i][j] == DIAG) {
+
80 lcs[--lcsl] = s1[i-1];
+
81 i = i - 1;
+
82 j = j - 1;
+
83 }
+
84 else if (B[i][j] == LEFT)
+
85 {
+
86 j = j - 1;
+
87 }
+
88 else
+
89 {
+
90 i = i - 1;
+
91 }
+
92 }
+
93 return lcs;
+
94}
#define calloc(elemCount, elemSize)
This macro replace the standard calloc function with calloc_dbg.
Definition: malloc_dbg.h:22
Definition: list.h:8
@@ -298,41 +302,43 @@ Functions
-

@breif Computes LCS between s1 and s2 using a dynamic-programming approach

+

Computes LCS between s1 and s2 using a dynamic-programming approach.

Parameters
- - - - - - + + + + + +
1s1 first null-terminated string
2s2 second null-terminated string
3l1 length of s1
4l2 length of s2
5L matrix of size l1 x l2
6B matrix of size l1 x l2
s1first null-terminated string
s2second null-terminated string
l1length of s1
l2length of s2
Lmatrix of size l1 x l2
Bmatrix of size l1 x l2
Returns
void
-
27 {
-
28 /* B is the directions matrix
-
29 L is the LCS matrix */
-
30 int i, j;
-
31
-
32 /* loop over the simbols in my sequences
-
33 save the directions according to the LCS */
-
34 for (i = 1; i <= l1; ++i)
-
35 for (j = 1; j <= l2; ++j)
-
36 if (s1[i-1] == s2[j-1]) {
-
37 L[i][j] = 1 + L[i-1][j-1];
-
38 B[i][j] = DIAG;
-
39 }
-
40 else if (L[i-1][j] < L[i][j-1]) {
-
41 L[i][j] = L[i][j-1];
-
42 B[i][j] = LEFT;
-
43 }
-
44 else {
-
45 L[i][j] = L[i-1][j];
-
46 B[i][j] = UP;
-
47 }
-
48}
+
30 {
+
31 /* B is the directions matrix
+
32 L is the LCS matrix */
+
33 int i, j;
+
34
+
35 /* loop over the simbols in my sequences
+
36 save the directions according to the LCS */
+
37 for (i = 1; i <= l1; ++i) {
+
38 for (j = 1; j <= l2; ++j) {
+
39 if (s1[i-1] == s2[j-1]) {
+
40 L[i][j] = 1 + L[i-1][j-1];
+
41 B[i][j] = DIAG;
+
42 }
+
43 else if (L[i-1][j] < L[i][j-1]) {
+
44 L[i][j] = L[i][j-1];
+
45 B[i][j] = LEFT;
+
46 }
+
47 else {
+
48 L[i][j] = L[i-1][j];
+
49 B[i][j] = UP;
+
50 }
+
51 }
+
52 }
+
53}
@@ -371,11 +377,11 @@ Functions
Returns
0 on exit
-
150 {
-
151 test(); // run self-test implementations
-
152 return 0;
-
153}
-
static void test()
Self-test implementations.
Definition: lcs.c:90
+
162 {
+
163 test(); // run self-test implementations
+
164 return 0;
+
165}
+
static void test()
Self-test implementations.
Definition: lcs.c:100
Here is the call graph for this function:
@@ -411,61 +417,63 @@ Here is the call graph for this function:

Self-test implementations.

Returns
void
-
90 {
-
91 /* https://en.wikipedia.org/wiki/Subsequence#Applications */
-
92 int **L, **B, j, l1, l2;
-
93
-
94 char *s1 = "ACGGTGTCGTGCTATGCTGATGCTGACTTATATGCTA";
-
95 char *s2 = "CGTTCGGCTATCGTACGTTCTATTCTATGATTTCTAA";
-
96 char *lcs;
-
97
-
98 l1 = strlen(s1);
-
99 l2 = strlen(s2);
-
100
-
101 L = (int **)calloc(l1+1, sizeof(int *));
-
102 B = (int **)calloc(l1+1, sizeof(int *));
+
100 {
+
101 /* https://en.wikipedia.org/wiki/Subsequence#Applications */
+
102 int **L, **B, j, l1, l2;
103
-
104 if (!L) {
-
105 perror("calloc: ");
-
106 exit(1);
-
107 }
-
108 if (!B) {
-
109 perror("calloc: ");
-
110 exit(1);
-
111 }
-
112 for (j = 0; j <= l1; j++) {
-
113 L[j] = (int *)calloc(l2+1, sizeof(int));
-
114 if (!L[j]) {
-
115 perror("calloc: ");
-
116 exit(1);
-
117 }
-
118 B[j] = (int *)calloc(l2+1, sizeof(int));
-
119 if (!L[j]) {
-
120 perror("calloc: ");
-
121 exit(1);
-
122 }
-
123 }
-
124
-
125 lcslen(s1, s2, l1, l2, L, B);
-
126 lcs = lcsbuild(s1, l1, l2, L, B);
-
127
-
128 assert(L[l1][l2] == 27);
-
129 assert(strcmp(lcs, "CGTTCGGCTATGCTTCTACTTATTCTA") == 0);
-
130
-
131 printf("S1: %s\tS2: %s\n", s1, s2);
-
132 printf("LCS len:%3d\n", L[l1][l2]);
-
133 printf("LCS: %s\n", lcs);
-
134
-
135 free(lcs);
-
136 for (j = 0; j <= l1; j++)
-
137 free(L[j]), free(B[j]);
-
138 free(L);
-
139 free(B);
-
140
-
141 printf("All tests have successfully passed!\n");
-
142}
-
char * lcsbuild(const char *s1, int l1, int l2, int **L, int **B)
@breif Builds the LCS according to B using a traceback approach
Definition: lcs.c:59
-
void lcslen(const char *s1, const char *s2, int l1, int l2, int **L, int **B)
@breif Computes LCS between s1 and s2 using a dynamic-programming approach
Definition: lcs.c:27
+
104 char *s1 = "ACGGTGTCGTGCTATGCTGATGCTGACTTATATGCTA";
+
105 char *s2 = "CGTTCGGCTATCGTACGTTCTATTCTATGATTTCTAA";
+
106 char *lcs;
+
107
+
108 l1 = strlen(s1);
+
109 l2 = strlen(s2);
+
110
+
111 L = (int **)calloc(l1+1, sizeof(int *));
+
112 B = (int **)calloc(l1+1, sizeof(int *));
+
113
+
114 if (!L) {
+
115 perror("calloc: ");
+
116 exit(1);
+
117 }
+
118 if (!B) {
+
119 perror("calloc: ");
+
120 exit(1);
+
121 }
+
122 for (j = 0; j <= l1; j++) {
+
123 L[j] = (int *)calloc(l2+1, sizeof(int));
+
124 if (!L[j]) {
+
125 perror("calloc: ");
+
126 exit(1);
+
127 }
+
128 B[j] = (int *)calloc(l2+1, sizeof(int));
+
129 if (!L[j]) {
+
130 perror("calloc: ");
+
131 exit(1);
+
132 }
+
133 }
+
134
+
135 lcslen(s1, s2, l1, l2, L, B);
+
136 lcs = lcsbuild(s1, l1, l2, L, B);
+
137
+
138 assert(L[l1][l2] == 27);
+
139 assert(strcmp(lcs, "CGTTCGGCTATGCTTCTACTTATTCTA") == 0);
+
140
+
141 printf("S1: %s\tS2: %s\n", s1, s2);
+
142 printf("LCS len:%3d\n", L[l1][l2]);
+
143 printf("LCS: %s\n", lcs);
+
144
+
145 free(lcs);
+
146 for (j = 0; j <= l1; j++)
+
147 {
+
148 free(L[j]), free(B[j]);
+
149 }
+
150 free(L);
+
151 free(B);
+
152
+
153 printf("All tests have successfully passed!\n");
+
154}
+
char * lcsbuild(const char *s1, int l1, int l2, int **L, int **B)
Builds the LCS according to B using a traceback approach.
Definition: lcs.c:64
+
void lcslen(const char *s1, const char *s2, int l1, int l2, int **L, int **B)
Computes LCS between s1 and s2 using a dynamic-programming approach.
Definition: lcs.c:30
#define free(ptr)
This macro replace the standard free function with free_dbg.
Definition: malloc_dbg.h:26
Here is the call graph for this function:
diff --git a/db/de1/lcs_8c_a0ddf1224851353fc92bfbff6f499fa97_cgraph.map b/db/de1/lcs_8c_a0ddf1224851353fc92bfbff6f499fa97_cgraph.map index 3b88f0c8..652ad681 100644 --- a/db/de1/lcs_8c_a0ddf1224851353fc92bfbff6f499fa97_cgraph.map +++ b/db/de1/lcs_8c_a0ddf1224851353fc92bfbff6f499fa97_cgraph.map @@ -1,6 +1,6 @@ - - + + diff --git a/db/de1/lcs_8c_a0ddf1224851353fc92bfbff6f499fa97_cgraph.md5 b/db/de1/lcs_8c_a0ddf1224851353fc92bfbff6f499fa97_cgraph.md5 index 4111832a..2b689b4b 100644 --- a/db/de1/lcs_8c_a0ddf1224851353fc92bfbff6f499fa97_cgraph.md5 +++ b/db/de1/lcs_8c_a0ddf1224851353fc92bfbff6f499fa97_cgraph.md5 @@ -1 +1 @@ -6f3f9dfa107f08ce6a4553449a150e13 \ No newline at end of file +a914b9badc6f3982f4c4215c81bb2459 \ No newline at end of file diff --git a/db/de1/lcs_8c_a0ddf1224851353fc92bfbff6f499fa97_cgraph.svg b/db/de1/lcs_8c_a0ddf1224851353fc92bfbff6f499fa97_cgraph.svg index 35f11d95..1ada304c 100644 --- a/db/de1/lcs_8c_a0ddf1224851353fc92bfbff6f499fa97_cgraph.svg +++ b/db/de1/lcs_8c_a0ddf1224851353fc92bfbff6f499fa97_cgraph.svg @@ -35,7 +35,7 @@ Node3 - + lcsbuild @@ -50,7 +50,7 @@ Node4 - + lcslen diff --git a/db/de1/lcs_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.map b/db/de1/lcs_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.map index 8a4cf77a..1945575c 100644 --- a/db/de1/lcs_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.map +++ b/db/de1/lcs_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.map @@ -1,5 +1,5 @@ - - + + diff --git a/db/de1/lcs_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 b/db/de1/lcs_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 index 84a3ecbb..e318811a 100644 --- a/db/de1/lcs_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 +++ b/db/de1/lcs_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 @@ -1 +1 @@ -6ad40ff4cb2627f0491bc779dcdf796b \ No newline at end of file +168c1754ac20194abd6ba84c259390f0 \ No newline at end of file diff --git a/db/de1/lcs_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg b/db/de1/lcs_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg index cf7a5835..04cb3c0f 100644 --- a/db/de1/lcs_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg +++ b/db/de1/lcs_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg @@ -20,7 +20,7 @@ Node2 - + lcsbuild @@ -35,7 +35,7 @@ Node3 - + lcslen