This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Function to generate a truth table (number of variables of the table (fixed number), number of variables of the table (recursive)) | |
def geraTabelaVerdade(m,n,tabelaVerdade): | |
bits=2**m # rows in the table, fixed value | |
repeticoes_coluna=(bits//(2**n))*2 | |
repeticoes_linha=(2**n//2)//2 | |
contador=0 | |
if not tabelaVerdade: # Create the first column | |
for i in range(bits // 2): | |
tabelaVerdade.append('0') | |
for i in range(bits // 2): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import scipy.linalg as la | |
import numpy.linalg as ln | |
#Busca valor de alpha | |
def LineSearch(f,g,x,p): | |
a,b = 1 - 2/(1 + np.sqrt(5)), 2/(1+np.sqrt(5)) | |
alpha = 1.0 | |
while (f(x+alpha*p) > f(x)) + a * alpha*np.dot(g(x),p) : | |
alpha *= b |