Skip to content
Snippets Groups Projects
Select Git revision
  • 259-refactor-background-update
  • dev default protected
  • 316-tracking-estimator
  • Thesis_hannes_merge_ready_versuch1
  • InboxWithNewOverview
  • 298-missing-backend-features-connections-for-ui
  • 293-integrate-attachment-functionality-in-new-composeview
  • 299-add-pull-to-refresh-to-maillistview
  • 290+Dev
  • 290-redesign-the-ContactView
  • 291-add-research-face-prototype
  • 292-add-comments-to-attachmentviewmain-swift
  • 302-fix-bug-attachment-previews-of-incoming-mails
  • 288-make-folders-list-slide-in-from-the-left-instead-of-from-the-right
  • 295-inboxview-maillistview-improvements
  • 294-fix-bugs-in-new-composeview
  • 287-redesign-composeview
  • updatePGP
  • 282-Implement-missing-functions-in-reply-button
  • 286-update-openssl
  • ThesisHannesV2_
  • runnable
  • optional_UI_change
  • dep
  • NoTestCase
25 results

PGPPKCSEmsa.h

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    test_quad_transformed.py 1.11 KiB
    import numpy as np
    import quadrature
    import polynomial_new as poly
    
    """ Settings: """
    # Parameters of the quadrature rule on reference interval:
    x = np.array([-1.0, 0.0, 1.0])
    w = np.array([1.0/3, 4.0/3, 1.0/3])
    
    # Define linear transformation of [-1, 1] to [1, 5]:
    a = 1.0
    b = 5.0
    T = lambda x: 2 * x + 3
    dT = 2.0
    # Number of tests:
    ntest = 10
    
    """ Function to integrate polynomial: """
    def int_poly(P, a, b):
        # Coefficients of the primitive function:
        pc = P.coeff / np.arange(1, P.deg+2, dtype=float)
        # Evaluate powers at both boundary points:
        bx = np.array([b**i for i in range(1, P.deg+2)])
        ax = np.array([a**i for i in range(1, P.deg+2)])
    
        return (pc @ bx - pc @ ax)
    
    
    """ Main Test: """
    S = quadrature.LinearTransformed(x, w)
    
    for ii in range(ntest):
        # Generate random third order polynomial:
        #c = np.array([1.0, 0.0, 0.0, 1.0])
        c = np.random.randn(4)
        print("Test %d: coeffs: "%ii, c)
        P = poly.polynomial(c)
        # Compute integral:
        I = int_poly(P, a, b)
        # Approximation with Simpson rule:
        ISimp = S.integrate(P, T, dT)
        print("Test %d: diff = "%ii, np.abs(I - ISimp))