MCPcopy Create free account
hub / github.com/numpy/numpy / hermmul

Function hermmul

numpy/polynomial/hermite.py:446–509  ·  view source on GitHub ↗

Multiply one Hermite series by another. Returns the product of two Hermite series `c1` * `c2`. The arguments are sequences of coefficients, from lowest order "term" to highest, e.g., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``. Parameters ---------- c1, c2 :

(c1, c2)

Source from the content-addressed store, hash-verified

444
445
446def hermmul(c1, c2):
447 """
448 Multiply one Hermite series by another.
449
450 Returns the product of two Hermite series `c1` * `c2`. The arguments
451 are sequences of coefficients, from lowest order "term" to highest,
452 e.g., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``.
453
454 Parameters
455 ----------
456 c1, c2 : array_like
457 1-D arrays of Hermite series coefficients ordered from low to
458 high.
459
460 Returns
461 -------
462 out : ndarray
463 Of Hermite series coefficients representing their product.
464
465 See Also
466 --------
467 hermadd, hermsub, hermmulx, hermdiv, hermpow
468
469 Notes
470 -----
471 In general, the (polynomial) product of two C-series results in terms
472 that are not in the Hermite polynomial basis set. Thus, to express
473 the product as a Hermite series, it is necessary to "reproject" the
474 product onto said basis set, which may produce "unintuitive" (but
475 correct) results; see Examples section below.
476
477 Examples
478 --------
479 >>> from numpy.polynomial.hermite import hermmul
480 >>> hermmul([1, 2, 3], [0, 1, 2])
481 array([52., 29., 52., 7., 6.])
482
483 """
484 # s1, s2 are trimmed copies
485 [c1, c2] = pu.as_series([c1, c2])
486
487 if len(c1) > len(c2):
488 c = c2
489 xs = c1
490 else:
491 c = c1
492 xs = c2
493
494 if len(c) == 1:
495 c0 = c[0]*xs
496 c1 = 0
497 elif len(c) == 2:
498 c0 = c[0]*xs
499 c1 = c[1]*xs
500 else:
501 nd = len(c)
502 c0 = c[-2]*xs
503 c1 = c[-1]*xs

Callers

nothing calls this directly

Calls 3

hermsubFunction · 0.85
hermaddFunction · 0.85
hermmulxFunction · 0.85

Tested by

no test coverage detected