public override System.Numerics.Complex F(double t, VectorOI y) { // A Dynamical Systems Approach to Musical Tonality. Equation 11. // Musical Tonality, Neural Resonance, and Hebbian Learning. Equation 3 (w/fix to assumed typo). NeuralOscillatorNode @in = Connection.From as NeuralOscillatorNode; NeuralOscillatorNode @out = Connection.To as NeuralOscillatorNode; Complex z_i = @in.Value; Complex z_j = @out.Value; Complex z_j_conj = Complex.Conjugate(z_j); double epsilon = (@in.Nonlinearity + @out.Nonlinearity) * 0.5; Complex c_dot; Complex c = y[this]; double delta = this.Connection.Decay; double k = this.Connection.Plasticity; Complex sqrtEpsZi = Complex.Sqrt(epsilon * z_i); Complex sqrtEpsZjConj = Complex.Sqrt(epsilon * z_j_conj); Complex term1 = -delta * c; Complex term2 = k; Complex term3 = z_i / (1 - sqrtEpsZi); Complex term4 = z_j_conj / (1 - sqrtEpsZjConj); c_dot = term1 + term2 * term3 * term4; return(c_dot); }
public override Complex F(double t, VectorOI y) { if (_doResetForcingFunctionTime) { _doResetForcingFunctionTime = false; _timeOffset = -t; } double timeForForcingFunction = t + _timeOffset; double derivative = 0.0; const double displacementDecay = 1.0; foreach (Note note in Notes) { foreach (short harmonicRatio in note.Harmonics) { double amplitude = note.Amplitude / (double)harmonicRatio; double frequency = note.FundamentalFrequency * (double)harmonicRatio; double twoPiFrequency = 2.0 * Math.PI * frequency; derivative += amplitude * twoPiFrequency * Math.Cos(twoPiFrequency * timeForForcingFunction); } } double normalizingTerm = Notes.Count; derivative = derivative / normalizingTerm - this.Value.Real * displacementDecay; return(derivative); }
public override System.Numerics.Complex F(double t, VectorOI y) { // "A canonical model for gradient...". Large 2010. Equation 20. // tau * z-dot = z * ( // a + b * |z|^2 + (d * eps * |z|^4) / (1 - eps * |z|^2) // ) // + x / (1 - x * (sqrt eps)) * 1 / (1 - z * (sqrt eps)) // // "Musical Tonality, Neural Resonance and Hebbian Learning. Large 2011. Equation 2. // z-dot = z * ( // alpha + i*omega + (beta1 + // // Compute total stimulus. Complex x = this.X(t, y); // Grab current value of this node. Complex z = y[this]; Complex zConj = Complex.Conjugate(z); //Debug.Assert(x.Magnitude < _sqrtInvEpsilon); //Debug.Assert(z.Magnitude < _sqrtInvEpsilon); // Compute sqrt(eps). double eps = this.Nonlinearity; double sqrtEps = Math.Sqrt(this.Nonlinearity); // Compute |z|. double zAbs = Complex.Abs(z); // Compute |z|^2 and |z|^4. double zAbs2 = zAbs * zAbs; double zAbs4 = zAbs2 * zAbs2; // Gather other constants. Complex a = this.A; Complex b = this.B; Complex d = this.D; double tau = 1.0 / this.CenterFrequency; //double tau = Math.PI * 2.0 / this.CenterFrequency; double tauInv = 1.0 / tau; // Compute parts. Complex part1 = z * (a + b * zAbs2 + (d * eps * zAbs4) / (1.0 - eps * zAbs2)); Complex part2 = x / (1.0 - x * sqrtEps); Complex part3 = 1.0 / (1.0 - zConj * sqrtEps); // Combine. Complex zDot = tauInv * (part1 + part2 * part3); // Done. return(zDot); }
public override Complex F(double t, VectorOI y) { Complex result = 0; foreach (var in_link in this.IncomingNodes) { var in_node = in_link.From; Complex in_value = y[in_node]; Complex subtotal = in_value * this.Coef1 + this.Coef0; result += subtotal; } return(result); }
/// <summary> /// Computes the total "stimulus" contribution from /// incoming nodes. /// </summary> protected Complex X(double t, VectorOI y) { Complex sum = 0.0; foreach (var link in this.IncomingNodes) { var node = link.From; Complex weight = link.Weight; Complex nodeValue = y[node]; Complex nodeTotal = nodeValue * weight; sum += nodeTotal; } return(sum); }