summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/netlist/solver/nld_ms_direct1.h
blob: 85bb0388168a5694e5f386f24b5cdd7a7a2a8868 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// license:GPL-2.0+
// copyright-holders:Couriersud
/*
 * nld_ms_direct1.h
 *
 */

#ifndef NLD_MS_DIRECT1_H_
#define NLD_MS_DIRECT1_H_

#include "solver/nld_ms_direct.h"
#include "solver/nld_solver.h"

NETLIB_NAMESPACE_DEVICES_START()

class matrix_solver_direct1_t: public matrix_solver_direct_t<1,1>
{
public:

	matrix_solver_direct1_t(const solver_parameters_t *params)
		: matrix_solver_direct_t<1, 1>(params, 1)
		{}
	ATTR_HOT inline int vsolve_non_dynamic(const bool newton_raphson);
protected:
	ATTR_HOT virtual nl_double vsolve();
private:
};

// ----------------------------------------------------------------------------------------
// matrix_solver - Direct1
// ----------------------------------------------------------------------------------------

ATTR_HOT nl_double matrix_solver_direct1_t::vsolve()
{
	solve_base<matrix_solver_direct1_t>(this);
	return this->compute_next_timestep();
}

ATTR_HOT inline int matrix_solver_direct1_t::vsolve_non_dynamic(ATTR_UNUSED const bool newton_raphson)
{
	analog_net_t *net = m_nets[0];
	this->build_LE_A();
	this->build_LE_RHS(m_RHS);
	//NL_VERBOSE_OUT(("%f %f\n", new_val, m_RHS[0] / m_A[0][0]);

	nl_double new_val =  m_RHS[0] / m_A[0][0];

	nl_double e = (new_val - net->m_cur_Analog);
	nl_double cerr = nl_math::abs(e);

	net->m_cur_Analog = new_val;

	if (is_dynamic() && (cerr  > m_params.m_accuracy))
	{
		return 2;
	}
	else
		return 1;

}

NETLIB_NAMESPACE_DEVICES_END()


#endif /* NLD_MS_DIRECT1_H_ */