Skip to content

bastian-polewka/criss-cross-algorithm-assignment7

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Criss-Cross Multiplication

A 50-lines algorithm for multiplying large positive integers in string format. For numbers having less than 100 digits, it outperforms the Karatsuba algorithm by as much as 50%.

Read more about the algorithm in this post.

Usage

Import mul.h in your program and initialise a Mul object as follows:

Mul Multiplier("9912", "54564");
Multiplier.vedic(); // 540838368

The Mul class has 3 methods for multiplication:

Method Description
basicVedic() A simpler and faster implementation of the criss-cross algorithm but is more limited since it uses basic arithmetic operators for addition and subtraction.
vedic() A version of basicVedic() that uses helper functions for adding and subtracting large string numbers.
karatsuba() Uses the Karatsuba algorithm for multiplication. Algorithm uses helper functions for adding and subtracting large string numbers.

References

About

Assignment 7: Explore and Illustrate C++ Performance Gains

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 99.0%
  • Makefile 1.0%