id
stringlengths
36
36
text
stringlengths
1
1.25M
6718ceb7-acc8-4158-88c9-6770b5df81c9
public double[] executar(String metodo) { double[] temp = {25, 25}; switch (metodos.valueOf(metodo)) { case Gauss: temp = ga.executar(matriz); break; case Cholesky: temp = cho.executar(matriz); break; ...
a9816d34-3a65-4baf-b059-52fa5f8ecfd0
public double[] executar(String metodo, double[]vetor,double erro) { double[] temp = {21, 21}; switch (metodos.valueOf(metodo)) { case Jacobi: temp = jo.executar(matriz, vetor, erro); break; case Seidel: temp = gs.executar(mat...
ae8816d9-3b77-472d-a405-873dbba542d3
public void printarResultado(double[] vet) { for(int i=0;i<vet.length;i++) { System.out.println(formatacaoSaida.format(vet[i])); } }
9a095301-1b61-4697-9060-889ba2ed71d1
public double[] executar(Matriz m) { matrizTemp = m; alocarVetores(); if(!ehSimetrica(A)) { //System.out.println("\n--Fatorção de Cholesky--"); System.out.println("Matriz não é simétrica para o método de Cholesky"); return this.resultado; } else i...
537f5821-246a-4a1a-a7c0-f5cc749d634d
public boolean ehSimetrica(double[][] matriz){ for(int i = 0,j = matriz.length -1 ; i < matriz.length ; i++,j--){ if(matriz[i][j] != matriz[j][i]){ return false; } } return true; }
815929bf-25d5-4359-b001-2754a087985e
public boolean ehPositivaDefinida(double[][] a){ double[][] u = a; double[][] m = new double[a.length][a[0].length]; for(int i = 0 ; i < a.length -1 ; i++){ setIdentidadeToMatriz(m); for(int j = i + 1 ; j < a.length ; j++){ m[j][i] = -u[j][i] / u[i][i]; } u = multiplicarMatrizes(m, u); } //pri...
cb9ef280-615f-477b-a14d-09f1495efcf7
public double[][] setIdentidadeToMatriz(double[][] matriz){ for(int index = 0 ; index < matriz.length ; index++){ for(int j = 0; j < matriz[0].length ; j++ ){ if(j == index){ matriz[index][j] = 1; } else{ matriz[...
e48a65de-f0aa-460c-958b-06d767fa4849
public double[][] multiplicarMatrizes(double[][] multiplicadora,double[][] multiplicando){ if(multiplicadora[0].length != multiplicando.length){ System.err.println("O tamanho das matrizes não são compatíveis"); return null; } double[][] resultadoTemp = new double[multiplicadora...
07429e7a-2583-46e3-863c-3090787f63a7
public double[][] cholesky(double[][] matriz) { double temp[][] = new double[linhas][colunas]; for (int i = 0; i < linhas; i++) { for (int j = 0; j <= i; j++) { double soma = 0.0; for (int k = 0; k < j; k++) { soma += temp[i][k] * temp[j][...
cbacff17-f42f-42fd-8781-d2eac1704dfa
public double [][] transposta(double[][]matriz) { double[][] temp = new double[linhas][colunas]; for (int i=0; i < linhas; ++i){ for (int j=0; j < colunas; ++j){ temp[j][i] = matriz [i][j]; } } return temp; }
20b7f209-eb85-41b8-8a5d-13d1a319fcef
private double[] calcularResultadoSuperior(double[][]matriz,double[]vetor) { double[] resultado = new double[linhas]; linhas--; // para facilitar os cáculos já que o indece de matrizes em java começam em zero! resultado[linhas] = vetor[linhas] / matriz[linhas][linhas];//calcula o ultimo x, ja...
9671ebda-473d-4112-92d4-ad0ca3f8fdb2
private double[] calcularResultadoInferior(double[][]matriz,double[]vetor) { double[] resultado = new double[linhas]; int i =0; resultado[i] = vetor[i] / matriz[i][i];//calcula o primeiro x, ja que o resultado e praticamente direto for (int k = 1; k <linhas; k++) {//começa em 1 pois...
371c5ad4-a44b-468a-b461-d19c3c6083c2
private void alocarVetores() { linhas = matrizTemp.linhas; colunas = matrizTemp.colunas-1;//menos 1 pois o nº de colunas é da matrizTemp ampliada resultado = new double[linhas]; for (int i = 0; i < this.linhas; i++) { this.resultado[i] = 0; } b...
4e8cab26-fe3b-42e6-abe6-88523cc2d90e
public static void main(String[] args) { selecionarInterface(0); JFrame frame = new Interface(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); //ajusta o tamanho da janela ao dos componentes frame.setResizable(false);//nao deixa o usuario aumentar o tamanho da ...
3d977568-9dca-4f68-a8b2-af3dc3a387ea
public static void selecionarInterface(int tipo) { String[] newLookAndFeel = { "com.sun.java.swing.plaf.gtk.GTKLookAndFeel", "javax.swing.plaf.metal.MetalLookAndFeel", "com.sun.java.swing.plaf.windows.WindowsLookAndFeel", "com.sun.java.swing.plaf.motif.MotifLookAn...
64410648-cd55-4d9a-8623-f7d596a2596f
public Matriz(int linhas,int colunas, double[][] vetor) { this.linhas = linhas; this.colunas = colunas; matrizAmpliada = new double [linhas][colunas]; termosIndependentes=new double[linhas];//coeficientes separados setMatrizAmpliada(vetor); }
f65fe847-b858-4efe-808b-43ef0c7d05a4
public Matriz(int linhas, int colunas){ this.linhas = linhas; this.colunas = colunas; matrizAmpliada = new double [linhas][colunas];//matriz e separa dos coeficientes pois necessario efetuar calculos apenas com ela termosIndependentes=new double[linhas];//coeficientes separados }
5c674638-1f4a-4ce0-8c28-7c7e4929e136
public Matriz() { //construtor vazio }
aeb461f2-fdc2-4bbd-800c-5483fb270ae0
public Matriz identidade() { Matriz identidade = new Matriz(); return identidade; }
e926ba44-d711-4965-9811-2237eb7f9682
public void setDimensao(int linhas, int colunas) { this.linhas = linhas; this.colunas = colunas; matriz = new double [linhas][colunas]; matrizAmpliada = new double [linhas][colunas]; }
14bd199f-1b36-4911-8b0e-9995b58fec1a
public void setMatrizAmpliada(double[][]m) { for(int i =0;i<linhas;i++) { System.arraycopy(m[i], 0, this.matrizAmpliada[i], 0, colunas); } setCoeficientes();//coloca os coeficientes em um vetor separado setMatriz();//separa a matriz sem os coeficientes }
603ce365-ce24-409d-989b-119185acfdee
private void setMatriz() { matriz = new double[linhas][colunas-1]; for(int i=0;i<linhas;i++) { System.arraycopy(matrizAmpliada[i], 0, matriz[i], 0, colunas-1);//nao coloca a ultima coluna, por isso colunas-1 } }
3403433d-22ff-4c65-8bde-b5db5631e3d3
private void setCoeficientes() { termosIndependentes = new double[linhas]; for(int i = 0;i<linhas;i++) { termosIndependentes[i]= matrizAmpliada[i][colunas-1]; } }
04070126-121e-4d97-b345-5330a43ca85e
public double[] getCoeficientes() { return termosIndependentes; }
bba471fa-bba8-4b4a-ab1e-eb922d6d8bd4
public double[][] getMatriz() { return matriz; }
88cac06d-a0bd-49f2-84b4-a50bdf7d61fd
public void setSolucao() { this.solucao = this.verificador(); }
c7f76dbe-fde4-41e5-90b9-2498f8526c1c
public String getSolucao() { return this.solucao; }
ad28f4a6-5559-46dc-8ddf-8e212717a657
public String verificador() { boolean flag; double fatorMult = 0; for (int i = 0; i < (this.linhas - 1); i++) { for (int j = i + 1; j < this.linhas; j++) { if (this.matriz[i][0] != 0) { fatorMult = (this.matriz[j][0] / this.matriz[i][0]); flag = true; for (int k...
b37bc897-87a9-4050-9450-50fae9483283
public GaussSeidel () { }
e125049a-eb9d-493f-bb7a-cc143b137ec7
public double[] executar (Matriz m, double[] vetor, double erro) { this.matriz = new Matriz(m.linhas, m.colunas); this.matriz.setMatrizAmpliada(m.matrizAmpliada); this.resultado = new double[m.linhas]; if (!this.verificarConvergencia()) { for(int i = 0; i < this.matriz.linhas; i++) { this.resultado[i]...
fdd02fe0-ef9c-4ab0-bd38-b6da671d152e
protected void calcular(double[] vetor) { double []anterior = new double[this.matriz.linhas]; System.arraycopy(vetor, 0, this.resultado, 0, vetor.length); do { for(int i = 0; i < this.matriz.linhas; i++) { System.arraycopy(this.resultado, 0, anterior, 0, resultado.length); this.res...
c4d3fcc9-c76a-4631-b42d-b18a142ac400
protected boolean verificarConvergencia() { boolean converge = false; for (int i = 0; i < this.matriz.linhas && !converge; i++) { for (int j = i + 1; j < this.matriz.linhas && !converge; j++) { if (this.criterioLinhas() && this.sassenfeld()) { converge = true; ...
4b8fb5cb-7eae-434c-acd9-dc4294a66fbb
private boolean sassenfeld() { double beta = 0; double []betaParcial = new double[this.matriz.linhas]; int i; for(i = 0; i < this.matriz.linhas; i++) { betaParcial[i] = 1; } for(i = 0; i < this.matriz.linhas; i++) { for(int j = 0; j < this.matriz.linhas; j++) { if(i != j) { beta = beta ...
3403e8f8-a54d-4cc2-ace1-35e1bd279a6e
public double[] executar(Matriz m) { temp = m; alocarVetores(); U = calcularTriangularSuperior(U);// matriz U deve ser calculada primeiro para pegar os elementos da matriz L // printaMatriz(U); L = calcularTriangularInferior(L); //printaMatriz(L); y = ...
3e0688d3-c5ae-4986-bd87-a12a4e5803d7
public double[][] calcularTriangularSuperior(double[][] matriz) { for(int k = 0; k < (linhas - 1); k++){ // Percorre linhas secundárias... Até o fim da matriz ou seja... até n for(int i = (k + 1); i < linhas; i++){ if(matriz[k][k]==0){//diagonal principal deve ser uni...
70ebb6a3-703e-49d3-bdbb-2b9c199cb5b6
public double[][] calcularTriangularInferior(double[][] matriz) { int k=0; for(int i = 0;i<temp.colunas-1;i++) { for(int j=0;j<linhas;j++) { if(i==j) { matriz[j][i]=1;//diagonal principal deve ser unitaria } ...
d8f588a2-4bbc-4a67-833e-7673dbf27a27
private double[] calcularResultadoSuperior(double[]vetor,double[][]matriz) { double[] resultado = new double[linhas]; linhas--; // para facilitar os cáculos já que o indece de matrizes em java começam em zero! resultado[linhas] = vetor[linhas] / matriz[linhas][linhas];//calcula o ultimo x, ja...
75690886-eece-4fe1-931d-e8305704d03b
private double[] calcularResultadoInferior(double[] vetor, double[][] matriz) { double[] resultado = new double[linhas]; int i =0; resultado[i] = vetor[i] / matriz[i][i];//calcula o primeiro x, ja que o resultado e praticamente direto for (int k = 1; k <linhas; k++) {//começa em 1 p...
3ea0e474-d0ec-4dff-a0e1-390be3c5123c
private void TrocarLinhas(int linha1, int linha2,double[][] matriz) { double aux = 0.00; // Troca elementos das linhas na matriz: a for (int i = 0; i < linhas; i++) { aux = matriz[linha1][i]; matriz[linha1][i] = matriz[linha2][i]; matriz[linha2][i] = aux; ...
6509e5f2-b9b7-427e-838b-7ee62a42f1fe
private double[] multiplicarMatrizesPorVetor(double[][] matriz, double[] vetor) { double[] resposta = new double[linhas]; double parcial; for(int i =0;i<linhas;i++) { for(int j=0;j<colunas;j++) { parcial = matriz[i][j]*vetor[j]; ...
9de38ee5-ab44-476b-98d6-0bba8c6988ce
private void alocarVetores() { linhas = temp.linhas; colunas = temp.colunas-1;//menos 1 pois o nº de colunas é da matriz ampliada b = new double[linhas]; x = new double[linhas];//cada linha vai ter um resultado y = new double[linhas]; L = new double[linhas][colunas];//a L...
ca7c4737-5131-48a2-869b-c2b1714f1c65
public void printaMatriz(double[][] matriz) { System.out.print("Resultado:\n "); for(int i=0;i<linhas;i++) { for(int j=0;j<colunas;j++) { System.out.print(matriz[i][j]+" | "); } System.out.println(); } }
a1a1d1c6-e08b-4a5c-9a6b-8b2e89dfd886
public Interface() { matrizPrincipal = new Matriz(); setTitle("Sistemas"); painelConfiguracoes = new JPanel(); painelConfiguracoes.setLayout(new GridLayout(17,0));// 17 botoes verticalmente insereConfiguracoes(); getContentPane().add(painelConfiguracoes, BorderLayout.WEST); }
7106cff3-3490-4eb9-b8c6-f5511d2acbe7
public void insereBotoesNoLayout() { int j=0,k=0; for (int i = 0; i < linhas*colunas; i++) { entradas[i] = new JTextField(); if(matrizArquivo==null) { //caso nao tem numeros para completar na matriz entradas[i].setText(""); //nao pode ter espaco, senao da problema...
7f561292-c7ce-4640-bc9b-6aec142d71d7
public void limparEntradasMatriz() { for (int i = 0; i < linhas*colunas; i++) { entradas[i].setText("");///nao pode ter espaco, senao da problema no parseInt } }
e4349074-cd03-499d-b5f5-f0b2f021bcd7
public void insereConfiguracoes() { botaoIniciar = new JButton("Iniciar"); botaoIniciar.setFocusable(false); botaoIniciar.addActionListener(new botaoIniciar()); botaoIniciar.setEnabled(false); botaoGerar = new JButton("Gerar Matriz"); botaoGerar.setFocusable(false); ...
a8c8b0c8-103b-4b92-8a7c-2273b3fd9603
@Override public void actionPerformed(ActionEvent e) { double[][] m = new double[linhas][colunas];//matriz temporaria para pegar os valores dos campos de texto int k = 0; for (int i = 0; i < linhas; i++) { for (int j = 0; j < colunas; j++) { ...
5a352633-3491-45ab-9095-2ba4df6a1f0b
private void criarTelaResultados() { Dimension boardSize = new Dimension(400, 200); frameResultados = new JFrame("Resultados"); //frameResultados.setResizable(false);//nao deixa o usuario aumentar o tamanho da tela frameResultados.setLocationRelativeTo(painelConfiguracoes...
b33c918b-d4ca-4763-9051-b1fe0f99a369
private void limparResultados() { labelResultados = new JLabel[(linhas+1) * 5];//cria um vetor de campos de texto do tamanho da matriz labelResultados[0] = new JLabel(); labelResultados[0].setText(" Gauss "); painelResultados.add(labelResultados[0]);//adiciona o campo de...
fa707f63-1e67-443a-98f6-f82ca7c0bdc8
private void adicionarResultados(double vetor[], int numeroMetodo) { NumberFormat format = NumberFormat.getInstance();//instancia o formatador de numeros format.setMaximumFractionDigits(6); //format.setMaximumIntegerDigits(10); String formatado;//string que serve ...
020c7cee-af64-450d-8272-8f2c7513088d
public void actionPerformed(ActionEvent e) { Dimension boardSize = new Dimension(200, 200); linhas = (Integer) spinnerLinhas.getValue(); colunas = (Integer) spinnerColunas.getValue(); matrizPrincipal = new Matriz(linhas,colunas); frameMatriz = n...
1aefb85c-b3a1-47cc-b7ac-ba06b4739528
@Override public void actionPerformed(ActionEvent e) { chooserFile = new JFileChooser(); final ExtensionFileFilter filter = new ExtensionFileFilter(); filter.adicionarExtensao(".csv"); filter.adicionarExtensao(".txt"); chooserFile.setFileFilter(filter)...
56c0adf8-6c78-485f-9ec7-92dc4ba3f53b
@Override public void actionPerformed(ActionEvent e) { textVetorInicial.setEnabled(true); textErro.setEnabled(true); }
40709906-2cce-4987-bb61-39f387f61be5
public void lerArquivo(File arquivo) throws FileNotFoundException, IOException { int y=0,z=0; BufferedReader bufferEntrada; String stringIn; StringTokenizer tokens; bufferEntrada = new BufferedReader(new FileReader(arquivo)); stringIn = bufferEntrada.readLine(); t...
0595f108-98bd-4e1b-abae-d267724e1cf9
public void mensagemSemSolucao() { JOptionPane.showMessageDialog(null, " Sistema nao possui SOLUCAO (SLI)!"); }
93da9d69-62a1-4572-8ec5-58602bdf6b78
public void mensagemInfinitasSolucoes() { JOptionPane.showMessageDialog(null, " Sistema possui INFINITAS solucoes (SLCI)!"); }
decbcca6-af1f-43f5-95e4-f9ec5152729c
private void adicionarExtensao(String tipo) { if (!tipo.startsWith(".")) { tipo = "." + tipo; } extensions.add(tipo); }
61aca3f3-c3c7-4c60-864e-89e3e930c8fe
@Override public boolean accept(File f) { if (f.isDirectory()) { return true;//aceita diretorios } String name = f.getName().toLowerCase();//pega o nome do arquivo selecionado e passa para minusculo for (String extension : extensions) {//for each...
0631804d-6a2d-451d-b99e-c16cbe06c848
@Override public String getDescription() { return "Arquivos contendo dados"; }
66e31155-394a-441e-a04a-ad9554cadfe4
public Integer getId() { return id; }
5b3e44ba-f767-4cea-9093-17657712e820
public void setId(Integer id) { this.id = id; }
fbbdb348-93e2-42db-803f-ed75764d31bf
public String getFirstName() { return firstName; }
60f942df-3679-47d6-a43f-0fba08fe4297
public void setFirstName(String firstName) { this.firstName = firstName; }
99fe87ab-803c-41ce-8c1d-cc9ef1307cff
public String getLastName() { return lastName; }
6d3ab52a-b3c5-494a-956b-511dd82958b0
public void setLastName(String lastName) { this.lastName = lastName; }
4094df8a-002e-4a89-a18a-e8b6bb9a778e
public String getEmail() { return email; }
3083bc78-8414-4097-9faf-68fef80f9950
public void setEmail(String email) { this.email = email; }
fe46dc3f-58b0-4fc3-932f-ba3c89ae9171
public Project getProject() { return project; }
050c1186-82a1-465a-ba09-61061d73438e
public void setProject(Project project) { this.project = project; }
3cb75362-cb76-4a6b-ae16-be42018cc26a
@Override public String toString() { return "Employee [id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + ", email=" + email + ", project=" + project + "]"; }
1baccc76-7c21-4373-9e7f-fea556d48c34
public String getId() { return id; }
958af33c-c388-404c-b6d2-7ff8e425c440
public void setId(String id) { this.id = id; }
87a83407-9b8b-43e7-83ed-c13787f68ebe
public String getName() { return name; }
09339f8d-7627-427e-87cb-238b2dffe392
public void setName(String name) { this.name = name; }
a711abc8-5f88-4516-9f70-ca095249d398
@Override public Set<Class<?>> getClasses() { Set<Class<?>> classes = new HashSet<Class<?>>(); classes.add(AdminResource.class); classes.add(UserResource.class); return super.getClasses(); }
13691b3a-c1f9-4951-8ebd-ff729b523aa2
@GET @Path("users") @Produces(MediaType.APPLICATION_JSON) public List<Employee> getAllEmployees() { return null; }
69c96716-e658-4256-ab6e-776ac7e517b4
@GET @Path("users/{id}") @Produces(MediaType.APPLICATION_JSON) public Employee getEmployee(@PathParam("id") Integer id) { return new Employee(); }
56b20401-bc2d-4068-8dea-74a4615988cb
@POST @Path("users/add") @Consumes(MediaType.APPLICATION_JSON) public void addUser(Employee employee) { System.out.println("adding user "+ employee.toString()); }
8b792c7a-8703-4b87-8b81-66181b9a9594
public AdministratorService() { // TODO Auto-generated constructor stub }
0c9314bf-49ce-484f-85f4-016b4c7fd105
public void act();
2d504d0f-7cb6-47e9-93d6-073e40a9b76c
public void draw(Graphics g);
0b59afee-2d58-43f7-9b86-1b241429bee6
public Panel() { }
0e3d092d-ad2d-43a5-a520-39ca34948f26
public void paint(Graphics g) { super.paint(g); if (!gameOver) { g.setColor(Color.gray); g.fillRect(0, 0, Main.WIDTH, Main.HEIGHT); g.setColor(Color.blue); if (sideTimer != 0) { wallHeight += wallSpeed; if (sideTimer == AIP...
b074b846-ee7b-4048-8cc0-c58904ef7c2f
public void setSideTimer(int side) { this.sideTimer = side; wallHeight = 0; if (side != 0) wallSpeed += 1; }
510edf70-0ae8-474a-a6eb-e9763354ee3a
public boolean timerHasRunOut() { return wallHeight >= Main.HEIGHT; }
c7b26aa9-2432-40e0-a662-f86c0ebb92b5
public void gameOver() { gameOver = true; }
8b34390b-311a-4d52-b4da-2ea746b4ef1e
public Main() { super("Throw the ball?"); setSize(WIDTH, HEIGHT); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); manager.setInteractionObjects(player, ai1, ai2, ball); manager.setPanel(panel); addKeyListener(this); // actables actables.add(ball); ...
6408a6e0-66c7-4245-808e-f28013554c75
public static void main(String[] args) { new Main().run(); }
35c7aa00-d380-425d-bf54-fd4bbdaf25f1
@Override public void run() { while (true) { try { // run manager manager.run(); // repaint panel.repaint(); Thread.sleep(3); } catch (Exception ex) { ex.printStackTrace(); } } }
943bbee4-3f94-45e0-8a77-edc6a14a4044
@Override public void keyTyped(KeyEvent e) { }
9dd67efa-ac60-400c-9bb5-0c17bfd9e7ce
@Override public void keyPressed(KeyEvent e) { }
02e8ddc6-9769-4fa8-b60c-0c4beb4c68f2
@Override public void keyReleased(KeyEvent e) { if (player.intersects(ball)) { if (e.getKeyCode() == e.VK_LEFT) { manager.turnOffWallTimer(); ball.setTarget((int) ai1.getCenterX(), (int) ai1.getCenterY()); } else if (e.getKeyCode() == e.VK_RIGHT) { ...
71db6340-4c25-4e74-9977-155801faae82
@Override public void run() { try { actables = Main.actables; for (int i = 0; i < actables.size(); i++) { ((Actable) actables.get(i)).act(); } interact(); if (gameOver) panel.gameOver(); Thread.sleep(...
52cedf20-cc6e-4eb9-8b8d-477d4179ec65
private void interact() { // TODO: Set it to track based on distance from each center // for now this will do... // ball possesion has changed is true when // previous balls target character == current ball holder ballPossesionHasChanged = ballTarget == currentBallHolder; ...
0977ceda-518f-4824-89c0-d82b6af00558
public void turnOffWallTimer() { panel.setSideTimer(0); }
45090d3e-fb2e-4281-a7c3-329468d006df
public void setInteractionObjects( Rectangle player, Rectangle ai1, Rectangle ai2, Rectangle ball) { this.player = player; this.ai1 = ai1; this.ai2 = ai2; this.ball = ball; }
fe49f2ed-b5a9-44e2-aa55-8e7745096c86
public void setPanel(Panel panel) { this.panel = panel; }
79046e3d-3c63-493b-959c-1c31e284464b
public Point getCharacterCoords(int playerCode) { switch (playerCode) { case AIPlayer.HUMAN: return new Point((int) player.getCenterX(), (int) player.getCenterY()); case AIPlayer.LEFT: return new Point((int) ai1.getCenterX(), (int) ai1.getCenterY()); ...
ad7a9ae2-7321-40bd-a8f2-538ab953f8a7
public Ball() { super(SIZE, SIZE); setLocation((int) x, (int) y); }
ba563baa-a329-47b3-ab0e-87cac26d0bb5
@Override public void draw(Graphics g) { g.fillOval((int) x, (int) y, SIZE, SIZE); }