Subversion Repositories programming

Rev

Rev 108 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 108 Rev 112
Line 20... Line 20...
20
 *  Changed the base case of multiply_dnq(). This gives a 4x speed up.
20
 *  Changed the base case of multiply_dnq(). This gives a 4x speed up.
21
 *  Added Strassen's Method
21
 *  Added Strassen's Method
22
 *
22
 *
23
 *  CODE IS FEATURE COMPLETE AT THIS POINT
23
 *  CODE IS FEATURE COMPLETE AT THIS POINT
24
 *
24
 *
-
 
25
 * 08-08-2005
-
 
26
 *  Changed to using a (hopefully) faster way of copying memory, using memcpy()
-
 
27
 *
-
 
28
 * 08-11-2005
-
 
29
 *  Testing shows that the memcpy() way of doing things is a little faster, but
-
 
30
 *  not by any significant amount. I'm leaving it here and enabled by default
-
 
31
 *  just for fun.
25
 */
32
 */
26
 
33
 
27
#include <stdio.h>
34
#include <stdio.h>
28
#include <stdlib.h>
35
#include <stdlib.h>
29
#include <time.h>
36
#include <time.h>
Line 383... Line 390...
383
}
390
}
384
 
391
 
385
/* copies a portion of the source to the destination */
392
/* copies a portion of the source to the destination */
386
void copymatrix (char **source, char **dest, int startrow, int startcol, int size)
393
void copymatrix (char **source, char **dest, int startrow, int startcol, int size)
387
{
394
{
-
 
395
    int i;
-
 
396
#ifndef FAST_MEMCPY
388
    int i, j;
397
    int j;
-
 
398
#endif
389
 
399
 
390
    for (i=0; i<size; i++)
400
    for (i=0; i<size; i++)
-
 
401
#ifdef FAST_MEMCPY
-
 
402
        memcpy (dest[i], source[i+startrow], sizeof(char)*size);
-
 
403
#else
391
        for (j=0; j<size; j++)
404
        for (j=0; j<size; j++)
392
            dest[i][j] = source[i+startrow][j+startcol];
405
            dest[i][j] = source[i+startrow][j+startcol];
393
 
406
#endif
394
}
407
}
395
 
408
 
396
/* copies from the source to a portion of the destination */
409
/* copies from the source to a portion of the destination */
397
void copymatrixback (char **source, char **dest, int startrow, int startcol, int size)
410
void copymatrixback (char **source, char **dest, int startrow, int startcol, int size)
398
{
411
{
-
 
412
    int i;
-
 
413
#ifndef FAST_MEMCPY
399
    int i, j;
414
    int j;
-
 
415
#endif
400
 
416
 
401
    for (i=0; i<size; i++)
417
    for (i=0; i<size; i++)
-
 
418
#ifdef FAST_MEMCPY
-
 
419
        memcpy (dest[i+startrow], source[i], sizeof(char)*size);
-
 
420
#else
402
        for (j=0; j<size; j++)
421
        for (j=0; j<size; j++)
403
            dest[i+startrow][j+startcol] = source[i][j];
422
            dest[i+startrow][j+startcol] = source[i][j];
-
 
423
#endif
404
 
424
 
405
}
425
}
406
 
426
 
407
/* adds two matrices together */
427
/* adds two matrices together */
408
void addmatrices (char **matrix1, char **matrix2, char **result, int size)
428
void addmatrices (char **matrix1, char **matrix2, char **result, int size)