|
From: Kakhkhor A. <kab...@gm...> - 2010-05-11 23:38:18
|
Dear All, Class LsmBasisSystem (lsmbasissystem.hpp) doesn't look good. Its implementation uses very inefficient and probability broken method to generate multidimensional basis functions from single factor basis functions. It generates many duplicates and then uses "remove-o-zap" method to remove them. The size of basis is not the same for different polynomial types. You can see the test results below. I reworked the implementation, so that basis sizes are the same for all polynomial types and no duplicates are created during the process. I would like to submit my code to QuantLib, but not sure how to do it. Regards, Kakhkhor Abdijalilov. ------------------------------------------------------------------------------------------------------------------------ The number of functions returned by multiPathBasisSystem method. In (n-m), n - size after "remove-o-zap", m - number of functions removed by "remove-o-zap" dimension = 1 order; Mnm; Lgr; Hrm; Hpr; Lgn; Chb; Chb2 ========================================= 0; 1-0; 1-0; 1-0; 1-0; 1-0; 1-0; 1-0 1; 2-0; 1-1; 2-0; 2-0; 2-0; 2-0; 2-0 2; 3-1; 3-1; 4-0; 3-1; 4-0; 4-0; 4-0 3; 4-4; 5-3; 6-2; 4-4; 7-1; 6-2; 7-1 4; 5-11; 10-6; 10-6; 7-9; 12-4; 10-6; 12-4 dimension = 2 order; Mnm; Lgr; Hrm; Hpr; Lgn; Chb; Chb2 ========================================= 0; 1-0; 1-0; 1-0; 1-0; 1-0; 1-0; 1-0 1; 3-0; 1-2; 3-0; 3-0; 3-0; 3-0; 3-0 2; 6-3; 6-3; 8-1; 6-3; 8-1; 8-1; 8-1 3; 10-17; 12-15; 16-11; 10-17; 18-9; 17-10; 18-9 4; 15-66; 32-49; 32-49; 20-61; 38-43; 35-46; 38-43 dimension = 3 order; Mnm; Lgr; Hrm; Hpr; Lgn; Chb; Chb2 ========================================= 0; 1-0; 1-0; 1-0; 1-0; 1-0; 1-0; 1-0 1; 4-0; 1-3; 4-0; 4-0; 4-0; 4-0; 4-0 2; 10-6; 10-6; 13-3; 10-6; 13-3; 13-3; 13-3 3; 20-44; 22-42; 32-32; 20-44; 35-29; 34-30; 35-29 4; 35-221; 73-183; 74-182; 44-212; 86-170; 82-174; 86-170 dimension = 4 order; Mnm; Lgr; Hrm; Hpr; Lgn; Chb; Chb2 ========================================= 0; 1-0; 1-0; 1-0; 1-0; 1-0; 1-0; 1-0 1; 5-0; 1-4; 5-0; 5-0; 5-0; 5-0; 5-0 2; 15-10; 15-10; 19-6; 15-10; 19-6; 19-6; 19-6 3; 35-90; 35-90; 55-70; 35-90; 59-66; 57-68; 59-66 4; 70-555; 140-485; 144-481; 84-541; 164-461; 154-471; 164-461 ------------------------------------------------------------------------------------------------------------------------ |