141 {
142 VF_R ret(order + 1);
143 for (Size i = 0; i <= order; ++i) {
144 switch (type) {
145 case QuantLib::LsmBasisSystem::Monomial:
146 ret[i] = MonomialFct(i);
147 break;
148 case QuantLib::LsmBasisSystem::Laguerre: {
149 GaussLaguerrePolynomial p;
150 ret[i] = [=](RandomVariable x) {
151 for (std::size_t i = 0; i < x.size(); ++i) {
152 x.set(i, p.weightedValue(i, x[i]));
153 }
154 return x;
155 };
156 } break;
157 case QuantLib::LsmBasisSystem::Hermite: {
158 GaussHermitePolynomial p;
159 ret[i] = [=](RandomVariable x) {
160 for (std::size_t i = 0; i < x.size(); ++i) {
161 x.set(i, p.weightedValue(i, x[i]));
162 }
163 return x;
164 };
165 } break;
166 case QuantLib::LsmBasisSystem::Hyperbolic: {
167 GaussHyperbolicPolynomial p;
168 ret[i] = [=](RandomVariable x) {
169 for (std::size_t i = 0; i < x.size(); ++i) {
170 x.set(i, p.weightedValue(i, x[i]));
171 }
172 return x;
173 };
174 } break;
175 case QuantLib::LsmBasisSystem::Legendre: {
176 GaussLegendrePolynomial p;
177 ret[i] = [=](RandomVariable x) {
178 for (std::size_t i = 0; i < x.size(); ++i) {
179 x.set(i, p.weightedValue(i, x[i]));
180 }
181 return x;
182 };
183 } break;
184 case QuantLib::LsmBasisSystem::Chebyshev: {
185 GaussChebyshevPolynomial p;
186 ret[i] = [=](RandomVariable x) {
187 for (std::size_t i = 0; i < x.size(); ++i) {
188 x.set(i, p.weightedValue(i, x[i]));
189 }
190 return x;
191 };
192 } break;
193 case QuantLib::LsmBasisSystem::Chebyshev2nd: {
194 GaussChebyshev2ndPolynomial p;
195 ret[i] = [=](RandomVariable x) {
196 for (std::size_t i = 0; i < x.size(); ++i) {
197 x.set(i, p.weightedValue(i, x[i]));
198 }
199 return x;
200 };
201 } break;
202 default:
203 QL_FAIL("unknown regression type");
204 }
205 }
206 return ret;
207}