#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Apr  9 15:36:29 2024

@author: dirk
"""
#%%

import numpy as np

b = [0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95]

Ml = []

for row in range(10):
    rowV = []
    for column in range(10):
        rowV.append(pow(b[column], row + 1))
    Ml.append(rowV)

M = np.array(Ml)

print("This is how amplitudes follow...")
with np.printoptions(precision=4, suppress=True):
    print(M)

print()


#%%

P = np.linalg.inv(M)

P = P * 1e-8

print("This is how wavelengths follow from amplitudes (*1e+8):")
with np.printoptions(precision=4, suppress=True, linewidth=120):
    print(P)

V = np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) * 1e8

print()

print("The common-mode vector is:")
with np.printoptions(precision=4, suppress=True, linewidth=120):
    print(P.dot(V))

print()


#%%

b = [0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95]


Ml = []

for row in range(8):
    rowV = []
    for column in range(8):
        rowV.append(pow(b[column], row + 1))
    Ml.append(rowV)

M = np.array(Ml)

print("This is how amplitudes follow...")
with np.printoptions(precision=4, suppress=True):
    print(M)

print()

P = np.linalg.inv(M)

P = P * 1e-6

print("This is how wavelengths follow from amplitudes (*1e+6):")
with np.printoptions(precision=4, suppress=True, linewidth=120):
    print(P)

V = np.array([1, 1, 1, 1, 1, 1, 1, 1]) * 1e6

print()

print("The common-mode vector is:")
with np.printoptions(precision=4, suppress=True, linewidth=120):
    print(P.dot(V))

print()

