Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch 2 #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
335 changes: 335 additions & 0 deletions Backup/Yttrium.sln

Large diffs are not rendered by default.

291 changes: 291 additions & 0 deletions Backup/src/app/MathNet.Yttrium/Builder.Service/Builder/Builder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,291 @@
#region Math.NET Yttrium (GPL) by Christoph Ruegg
// Math.NET Yttrium, part of the Math.NET Project
// http://mathnet.opensourcedotnet.info
//
// Copyright (c) 2001-2007, Christoph R�egg, http://christoph.ruegg.name
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#endregion

using System;
using System.Collections.Generic;

using MathNet.Symbolics.Backend;
using MathNet.Symbolics.Backend.Containers;
using MathNet.Symbolics.Library;

namespace MathNet.Symbolics.Builder
{
public class Builder : IBuilder
{
private readonly ILibrary _library;

internal Builder()
{
_library = Service<ILibrary>.Instance;
}

#region Building Single-Value Functions
public Signal Function(IEntity entity, Signal argument)
{
Port port = entity.InstantiatePort(argument);

if(port.InputSignalCount != 1 || port.OutputSignalCount != 1)
throw new MathNet.Symbolics.Exceptions.EntitySignalCountUnexpectedException("1 input and 1 output", port.InputSignalCount.ToString(Config.InternalNumberFormat) + " input and " + port.OutputSignalCount.ToString(Config.InternalNumberFormat) + " output");

return port[0];
}
public Signal Function(IEntity entity, Signal argument1, Signal argument2)
{
Port port = entity.InstantiatePort(argument1, argument2);

if(port.InputSignalCount != 2 || port.OutputSignalCount != 1)
throw new MathNet.Symbolics.Exceptions.EntitySignalCountUnexpectedException("2 input and 1 output", port.InputSignalCount.ToString(Config.InternalNumberFormat) + " input and " + port.OutputSignalCount.ToString(Config.InternalNumberFormat) + " output");

return port[0];
}
public Signal Function(IEntity entity, params Signal[] arguments)
{
Port port = entity.InstantiatePort(arguments);

if(port.InputSignalCount != arguments.Length || port.OutputSignalCount != 1)
throw new MathNet.Symbolics.Exceptions.EntitySignalCountUnexpectedException(arguments.Length.ToString(Config.InternalNumberFormat) + " input and 1 output", port.InputSignalCount.ToString(Config.InternalNumberFormat) + " input and " + port.OutputSignalCount.ToString(Config.InternalNumberFormat) + " output");

return port[0];
}
public Signal Function(IEntity entity, IList<Signal> arguments)
{
Port port = entity.InstantiatePort(arguments);

if(port.InputSignalCount != arguments.Count || port.OutputSignalCount != 1)
throw new MathNet.Symbolics.Exceptions.EntitySignalCountUnexpectedException(arguments.Count.ToString(Config.InternalNumberFormat) + " input and 1 output", port.InputSignalCount.ToString(Config.InternalNumberFormat) + " input and " + port.OutputSignalCount.ToString(Config.InternalNumberFormat) + " output");

return port[0];
}

public Signal Function(string symbol, Signal argument)
{
return Function(_library.LookupEntity(symbol, 1, 1, 0), argument);
}
public Signal Function(string symbol, Signal argument1, Signal argument2)
{
return Function(_library.LookupEntity(symbol, 2, 1, 0), argument1, argument2);
}
public Signal Function(string symbol, params Signal[] arguments)
{
if(arguments == null)
throw new ArgumentNullException("arguments");

return Function(_library.LookupEntity(symbol, arguments.Length, 1, 0), arguments);
}
public Signal Function(string symbol, IList<Signal> arguments)
{
if(arguments == null)
throw new ArgumentNullException("arguments");

return Function(_library.LookupEntity(symbol, arguments.Count, 1, 0), arguments);
}

public Signal Function(string symbol, InfixNotation notation, Signal argument)
{
return Function(_library.LookupEntity(symbol, notation, 1, 1, 0), argument);
}
public Signal Function(string symbol, InfixNotation notation, Signal argument1, Signal argument2)
{
return Function(_library.LookupEntity(symbol, notation, 2, 1, 0), argument1, argument2);
}
public Signal Function(string symbol, InfixNotation notation, params Signal[] arguments)
{
if(arguments == null)
throw new ArgumentNullException("arguments");

return Function(_library.LookupEntity(symbol, notation, arguments.Length, 1, 0), arguments);
}
public Signal Function(string symbol, InfixNotation notation, IList<Signal> arguments)
{
if(arguments == null)
throw new ArgumentNullException("arguments");

return Function(_library.LookupEntity(symbol, notation, arguments.Count, 1, 0), arguments);
}

public Signal Function(MathIdentifier entityId, Signal argument)
{
return Function(_library.LookupEntity(entityId), argument);
}
public Signal Function(MathIdentifier entityId, Signal argument1, Signal argument2)
{
return Function(_library.LookupEntity(entityId), argument1, argument2);
}
public Signal Function(MathIdentifier entityId, params Signal[] arguments)
{
return Function(_library.LookupEntity(entityId), arguments);
}
public Signal Function(MathIdentifier entityId, IList<Signal> arguments)
{
return Function(_library.LookupEntity(entityId), arguments);
}
#endregion

#region Building Multiple-Value Functions
public ReadOnlySignalSet Functions(IEntity entity, Signal argument)
{
Port port = entity.InstantiatePort(argument);

if(port.InputSignalCount != 1)
throw new MathNet.Symbolics.Exceptions.EntitySignalCountUnexpectedException("1 input", port.InputSignalCount.ToString(Config.InternalNumberFormat) + " input");

return port.OutputSignals;
}
public ReadOnlySignalSet Functions(IEntity entity, Signal argument1, Signal argument2)
{
Port port = entity.InstantiatePort(argument1, argument2);

if(port.InputSignalCount != 2 || port.OutputSignalCount != 1)
throw new MathNet.Symbolics.Exceptions.EntitySignalCountUnexpectedException("2 input", port.InputSignalCount.ToString(Config.InternalNumberFormat) + " input");

return port.OutputSignals;
}
public ReadOnlySignalSet Functions(IEntity entity, params Signal[] arguments)
{
Port port = entity.InstantiatePort(arguments);

if(port.InputSignalCount != arguments.Length || port.OutputSignalCount != 1)
throw new MathNet.Symbolics.Exceptions.EntitySignalCountUnexpectedException(arguments.Length.ToString(Config.InternalNumberFormat) + " input", port.InputSignalCount.ToString(Config.InternalNumberFormat) + " input");

return port.OutputSignals;
}
public ReadOnlySignalSet Functions(IEntity entity, IList<Signal> arguments)
{
Port port = entity.InstantiatePort(arguments);

if(port.InputSignalCount != arguments.Count || port.OutputSignalCount != 1)
throw new MathNet.Symbolics.Exceptions.EntitySignalCountUnexpectedException(arguments.Count.ToString(Config.InternalNumberFormat) + " input", port.InputSignalCount.ToString(Config.InternalNumberFormat) + " input");

return port.OutputSignals;
}

public ReadOnlySignalSet Functions(string symbol, Signal argument)
{
return Functions(_library.LookupEntity(symbol, 1, 1, 0), argument);
}
public ReadOnlySignalSet Functions(string symbol, Signal argument1, Signal argument2)
{
return Functions(_library.LookupEntity(symbol, 2, 1, 0), argument1, argument2);
}
public ReadOnlySignalSet Functions(string symbol, params Signal[] arguments)
{
return Functions(_library.LookupEntity(symbol, arguments.Length, 1, 0), arguments);
}
public ReadOnlySignalSet Functions(string symbol, IList<Signal> arguments)
{
return Functions(_library.LookupEntity(symbol, arguments.Count, 1, 0), arguments);
}

public ReadOnlySignalSet Functions(string symbol, InfixNotation notation, Signal argument)
{
return Functions(_library.LookupEntity(symbol, notation, 1, 1, 0), argument);
}
public ReadOnlySignalSet Functions(string symbol, InfixNotation notation, Signal argument1, Signal argument2)
{
return Functions(_library.LookupEntity(symbol, notation, 2, 1, 0), argument1, argument2);
}
public ReadOnlySignalSet Functions(string symbol, InfixNotation notation, params Signal[] arguments)
{
return Functions(_library.LookupEntity(symbol, notation, arguments.Length, 1, 0), arguments);
}
public ReadOnlySignalSet Functions(string symbol, InfixNotation notation, IList<Signal> arguments)
{
return Functions(_library.LookupEntity(symbol, notation, arguments.Count, 1, 0), arguments);
}

public ReadOnlySignalSet Functions(MathIdentifier entityId, Signal argument)
{
return Functions(_library.LookupEntity(entityId), argument);
}
public ReadOnlySignalSet Functions(MathIdentifier entityId, Signal argument1, Signal argument2)
{
return Functions(_library.LookupEntity(entityId), argument1, argument2);
}
public ReadOnlySignalSet Functions(MathIdentifier entityId, params Signal[] arguments)
{
return Functions(_library.LookupEntity(entityId), arguments);
}
public ReadOnlySignalSet Functions(MathIdentifier entityId, IList<Signal> arguments)
{
return Functions(_library.LookupEntity(entityId), arguments);
}
#endregion

#region Basic Encapsulation Multiplexing
public Signal EncapsulateAsVector(params Signal[] inner)
{
throw new NotImplementedException(MathNet.Symbolics.Properties.Resources.ex_NotImplementedYet);
}
public Signal EncapsulateAsVector(IList<Signal> inner)
{
throw new NotImplementedException(MathNet.Symbolics.Properties.Resources.ex_NotImplementedYet);
}
public Signal EncapsulateAsList(params Signal[] inner)
{
throw new NotImplementedException(MathNet.Symbolics.Properties.Resources.ex_NotImplementedYet);
}
public Signal EncapsulateAsList(IList<Signal> inner)
{
throw new NotImplementedException(MathNet.Symbolics.Properties.Resources.ex_NotImplementedYet);
}
public Signal EncapsulateAsSet(params Signal[] inner)
{
throw new NotImplementedException(MathNet.Symbolics.Properties.Resources.ex_NotImplementedYet);
}
public Signal EncapsulateAsSet(IList<Signal> inner)
{
throw new NotImplementedException(MathNet.Symbolics.Properties.Resources.ex_NotImplementedYet);
}
public Signal EncapsulateAsScalar(params Signal[] inner)
{
throw new NotImplementedException(MathNet.Symbolics.Properties.Resources.ex_NotImplementedYet);
}
public Signal EncapsulateAsScalar(IList<Signal> inner)
{
throw new NotImplementedException(MathNet.Symbolics.Properties.Resources.ex_NotImplementedYet);
}
#endregion

#region Basic Signal Manipulation
public Port MapSignals(Signal source, Signal target)
{
Port port = _library.LookupEntity(new MathIdentifier("Transport", "Std")).InstantiatePort(new Signal[] { source }, new Signal[] { target });

if(port.InputSignalCount != 1 || port.OutputSignalCount != 1)
throw new MathNet.Symbolics.Exceptions.EntitySignalCountUnexpectedException("1 input and 1 output", port.InputSignalCount.ToString(Config.InternalNumberFormat) + " input and " + port.OutputSignalCount.ToString(Config.InternalNumberFormat) + " output");
return port;
}
public Port MapSignalsSynchronized(Signal source, Signal target, Signal clock)
{
Port port = _library.LookupEntity(new MathIdentifier("Sync", "Std")).InstantiatePort(new Signal[] { source, clock }, new Signal[] { target });

if(port.InputSignalCount != 2 || port.OutputSignalCount != 1)
throw new MathNet.Symbolics.Exceptions.EntitySignalCountUnexpectedException("2 input and 1 output", port.InputSignalCount.ToString(Config.InternalNumberFormat) + " input and " + port.OutputSignalCount.ToString(Config.InternalNumberFormat) + " output");

return port;
}
public Signal Synchronize(Signal signal, Signal clock)
{
return Function(new MathIdentifier("Sync", "Std"), signal, clock);
}
#endregion
}
}
35 changes: 35 additions & 0 deletions Backup/src/app/MathNet.Yttrium/Builder.Service/BuilderFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#region Math.NET Yttrium (GPL) by Christoph Ruegg
// Math.NET Yttrium, part of the Math.NET Project
// http://mathnet.opensourcedotnet.info
//
// Copyright (c) 2001-2007, Christoph R�egg, http://christoph.ruegg.name
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#endregion

using System;
using System.Collections.Generic;
using System.Text;

namespace MathNet.Symbolics
{
internal class BuilderFactory : IFactory<IBuilder>
{
IBuilder IFactory<IBuilder>.GetInstance()
{
return new Builder.Builder();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Math.NET Yttrium, part of the Math.NET Project
// http://mathnet.opensourcedotnet.info
//
// Copyright (c) 2001-2007, Christoph Rüegg, http://christoph.ruegg.name
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security.Permissions;

[assembly: AssemblyTitle("Math.NET Yttrium Library")]
[assembly: AssemblyDescription("http://mathnet.opensourcedotnet.info")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Math.NET Project")]
[assembly: AssemblyProduct("Math.NET")]
[assembly: AssemblyCopyright("Copyright © 2007, Math.NET Project")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: CLSCompliant(true)]
[assembly: ComVisible(false)]

[assembly: SecurityPermission(SecurityAction.RequestRefuse)]

[assembly: Guid("a56c26f4-8a54-4cf1-b6a2-8476c542263c")]

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Loading