public CLocalLimit(DateTime date, e_Direction direction) { _date = date; _dir = direction; _func = new function(_date, _dir); }
public SetFieldScript(WorldModel worldModel, IFunction<Element> obj, IFunction<string> field, IFunction<object> value) { m_worldModel = worldModel; m_obj = obj; m_field = field; m_value = value; }
public ListAddScript(ScriptContext scriptContext, IFunctionGeneric list, IFunction<object> value) { m_scriptContext = scriptContext; m_list = list; m_value = value; m_worldModel = scriptContext.WorldModel; }
public double Integrate(IFunction<Vector2, double> function) { double output = 0; foreach (var finiteElement in FiniteElements) ;//output += finiteElement.Integrate(function); return output; }
Plot2DValue Plot(IFunction f, Double minx, Double maxx, Double precision) { var cp = new Plot2DValue(); var N = (Int32)((maxx - minx) / precision) + 1; var M = new MatrixValue(N, 2); var x = new ScalarValue(minx); for (var i = 0; i < N; i++) { var row = i + 1; var y = f.Perform(Context, x); M[row, 1] = x.Clone(); if (y is ScalarValue) { M[row, 2] = (ScalarValue)y; } else if (y is MatrixValue) { var Y = (MatrixValue)y; for (var j = 1; j <= Y.Length; j++) { M[row, j + 1] = Y[j]; } } x.Re += precision; } cp.AddPoints(M); return cp; }
public RunDelegateScript(WorldModel worldModel, IFunction<Element> obj, IFunction<string> del, IList<IFunction<object>> parameters) { m_worldModel = worldModel; m_delegate = del; m_parameters = new FunctionCallParameters(worldModel, parameters); m_appliesTo = obj; }
/// <summary> /// Constructs with the details of teh function regression problem to be visualized. /// </summary> /// <param name="func">The function being regressed.</param> /// <param name="xMin">The minimum value of the input range being sampled.</param> /// <param name="xIncr">The increment between input sample values.</param> /// <param name="sampleCount">The number of samples over the input range.</param> /// <param name="genomeDecoder">Genome decoder.</param> public FunctionRegressionView2D(IFunction func, double xMin, double xIncr, int sampleCount, IGenomeDecoder<NeatGenome,IBlackBox> genomeDecoder) { InitializeComponent(); InitGraph(string.Empty, string.Empty, string.Empty); _func = func; _xMin = xMin; _xIncr = xIncr; _sampleCount = sampleCount; _genomeDecoder = genomeDecoder; // Prebuild plot point objects. _plotPointListTarget = new PointPairList(); _plotPointListResponse = new PointPairList(); double[] args = new double[]{xMin}; for(int i=0; i<sampleCount; i++, args[0] += xIncr) { _plotPointListTarget.Add(args[0], _func.GetValue(args)); _plotPointListResponse.Add(args[0], 0.0); } // Bind plot points to graph. zed.GraphPane.AddCurve("Target", _plotPointListTarget, Color.Black, SymbolType.None); zed.GraphPane.AddCurve("Network Response", _plotPointListResponse, Color.Red, SymbolType.None); }
internal SetScriptBase(SetScriptConstructor constructor, IFunction appliesTo, string property, GameLoader loader) { m_constructor = constructor; AppliesTo = appliesTo; Property = property; m_loader = loader; }
public PlaySoundScript(WorldModel worldModel, IFunction<string> function, IFunction<bool> synchronous, IFunction<bool> loop) { m_worldModel = worldModel; m_filename = function; m_synchronous = synchronous; m_loop = loop; }
public SimpleFuzzyRules(double[][] dataIn, IFunction function, List<FuzzySet> fuzzySets) { this.function = function; this.dataIn = dataIn; dataOut = getDataOutputs(); rules = generateRules(fuzzySets); }
public override void Execute(IFunction function, ResultRecord result) { double value; var votes = GetVotes().ToList(); function.Calculate(votes, result.ContentItemRecord.Id, out value); result.Value = value; result.Count = votes.Count; }
public DictionaryAddScript(WorldModel worldModel, IFunctionGeneric dictionary, IFunction<string> key, IFunction<object> value) { m_dictionary = dictionary; m_key = key; m_value = value; m_worldModel = worldModel; }
public override void Execute(IFunction function, ResultRecord result) { double value; function.Create(result.Value, result.Count, Vote, out value); result.Value = value; result.Count++; }
public DoActionScript(ScriptContext scriptContext, IFunction<Element> obj, IFunction<string> action) { m_scriptContext = scriptContext; m_worldModel = scriptContext.WorldModel; m_obj = obj; m_action = action; }
public CreateExitScript(WorldModel worldModel, IFunction<string> name, IFunction<Element> from, IFunction<Element> to) { m_worldModel = worldModel; m_name = name; m_from = from; m_to = to; }
public IfScript(IFunction<bool> expression, IScript thenScript, IScript elseScript, WorldModel worldModel) { m_expression = expression; m_thenScript = thenScript; m_elseScript = elseScript; m_worldModel = worldModel; }
internal SetScriptBase(SetScriptConstructor constructor, IFunction<Element> appliesTo, string property) { m_constructor = constructor; m_worldModel = constructor.WorldModel; AppliesTo = appliesTo; Property = property; }
public RequestScript(ScriptContext scriptContext, string request, IFunction<string> data) { m_scriptContext = scriptContext; m_worldModel = scriptContext.WorldModel; m_data = data; m_request = (Request)(Enum.Parse(typeof(Request), request)); }
public void SetCurrentFrame(IFrame currentFrame) { if (currentFrame == null || currentFrame.Function != _lastFunction) { instructionsListView.Items.Clear(); _lastFunction = null; } if (currentFrame != null) { if (currentFrame.Function == _lastFunction) { foreach (var item in instructionsListView.Items.Cast<MsilInstructionListViewItem>()) item.UpdateItem(currentFrame); } else { _lastFunction = currentFrame.Function; var bytes = ((RuntimeFunction)currentFrame.Function).IlCode.GetBytes(); var disassembler = new MsilDisassembler(new MemoryStreamReader(bytes), new DefaultOperandResolver()); foreach (var instruction in disassembler.Disassemble()) { var instructionBytes = new byte[instruction.Size]; Buffer.BlockCopy(bytes, instruction.Offset, instructionBytes, 0, instruction.Size); var item = new MsilInstructionListViewItem(instruction, instructionBytes); item.UpdateItem(currentFrame); instructionsListView.Items.Add(item); } } } }
static partial void __Uint8ClampedArray() { // https://code.google.com/p/chromium/issues/detail?id=176479 // X:\jsc.svn\examples\javascript\async\test\TestBytesFromSemaphore\TestBytesFromSemaphore\Application.cs // workers dont have Uint8ClampedArray ? // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/201501/20150103/uint8clampedarray // Native cctor shall call us // no other cctor shall do byte[] before this // how could we make sure Native cctor is ran first? // Uncaught TypeError: Cannot use 'in' operator to search for 'Uint8ClampedArray' in null // see also x:\jsc.svn\examples\javascript\Test\TestNewByteArray\TestNewByteArrayViaScriptCoreLib\Class1.cs if (Native.self == null) { // X:\jsc.svn\examples\javascript\forms\FakeWindowsLoginExperiment\FakeWindowsLoginExperiment\Library\Form1.cs return; } dynamic self = Native.self; self_Array = self.Array; self_Uint8ClampedArray = self.Uint8ClampedArray; //__Type.InternalTypeOfByteArrayViaMakeArrayType = typeof(byte[]); if (ScriptCoreLib.JavaScript.Runtime.Expando.Of(Native.self).Contains("Uint8ClampedArray")) return; // roslyn dynamic uses complex stack it seems. // dynamic site caching and if dont work well? if (ScriptCoreLib.JavaScript.Runtime.Expando.Of(Native.self).Contains("Uint8Array")) { // X:\jsc.svn\examples\javascript\Test\Test453DynamicAssignmentConditional\Test453DynamicAssignmentConditional\Class1.cs // IE its 2014! where is Uint8ClampedArray ??? // tested by // X:\jsc.svn\examples\javascript\Test\TestUploadValuesAsync\TestUploadValuesAsync\Application.cs // http://connect.microsoft.com/IE/feedback/details/781386/typed-array-support-is-incomplete-missing-uint8clampedarray-important-for-canvas Console.WriteLine("Uint8ClampedArray not available. while Uint8Array seems to be."); self.Uint8ClampedArray = self.Uint8Array; return; } // X:\jsc.svn\examples\javascript\test\TestTypeOfByteArray\TestTypeOfByteArray\Application.cs // X:\jsc.svn\examples\javascript\Test\Test453DynamicAssignment\Test453DynamicAssignment\Class1.cs // ArrayBuffer cannot be used with array can it? self.Uint8ClampedArray = self.Array; }
/// <summary>Defaults.</summary> /// <param name="d">The Descriptor to process.</param> /// <param name="x">The Vector to process.</param> /// <param name="y">The Vector to process.</param> /// <param name="activation">The activation.</param> /// <returns>A Network.</returns> public static Network Default(Descriptor d, Matrix x, Vector y, IFunction activation) { var nn = new Network(); // set output to number of choices of available // 1 if only two choices var distinct = y.Distinct().Count(); var output = distinct > 2 ? distinct : 1; // identity funciton for bias nodes IFunction ident = new Ident(); // set number of hidden units to (Input + Hidden) * 2/3 as basic best guess. var hidden = (int)Math.Ceiling((decimal)(x.Cols + output) * 2m / 3m); // creating input nodes nn.In = new Node[x.Cols + 1]; nn.In[0] = new Node { Label = "B0", Activation = ident }; for (var i = 1; i < x.Cols + 1; i++) { nn.In[i] = new Node { Label = d.ColumnAt(i - 1), Activation = ident }; } // creating hidden nodes var h = new Node[hidden + 1]; h[0] = new Node { Label = "B1", Activation = ident }; for (var i = 1; i < hidden + 1; i++) { h[i] = new Node { Label = string.Format("H{0}", i), Activation = activation }; } // creating output nodes nn.Out = new Node[output]; for (var i = 0; i < output; i++) { nn.Out[i] = new Node { Label = GetLabel(i, d), Activation = activation }; } // link input to hidden. Note: there are // no inputs to the hidden bias node for (var i = 1; i < h.Length; i++) { for (var j = 0; j < nn.In.Length; j++) { Edge.Create(nn.In[j], h[i]); } } // link from hidden to output (full) for (var i = 0; i < nn.Out.Length; i++) { for (var j = 0; j < h.Length; j++) { Edge.Create(h[j], nn.Out[i]); } } return nn; }
/// <summary> /// Constructor. /// </summary> /// <param name="function"> /// The function which this separator will mirror for visiblity. /// </param> public FunctionSeparator(IFunction function) { if (function != null) { IsVisible = function.IsVisible; function.IsVisibleChanged += function_IsVisibleChanged; } }
public IntegralTheard(ParametrsForIntegral param) { this.param = param; this.progress = 0; function = new Function1(); IntegralThr = new Thread(this.CalculateIntegral); IntegralThr.Start(); }
public WhileScript(ScriptContext scriptContext, IScriptFactory scriptFactory, IFunction<bool> expression, IScript loopScript) { m_scriptContext = scriptContext; m_worldModel = scriptContext.WorldModel; m_scriptFactory = scriptFactory; m_expression = expression; m_loopScript = loopScript; }
public void addListener( string eventname, IFunction callback ) { if( eventname == "data" ) { dataCallbacks.Add( callback ); } else if( eventname == "end" ) { endCallbacks.Add( callback ); } }
public void pushFunction(IFunction func) { if (stkFunction == null) { stkFunction = new Stack(); } stkFunction.Push(func); }
public ShowMenuScript(IScriptFactory scriptFactory, IFunction caption, IFunction options, IFunction allowCancel, IScript callbackScript) { m_scriptFactory = scriptFactory; m_caption = caption; m_options = options; m_allowCancel = allowCancel; m_callbackScript = callbackScript; }
public AskScript(ScriptContext scriptContext, IScriptFactory scriptFactory, IFunction<string> caption, IScript callbackScript) { m_scriptContext = scriptContext; m_worldModel = scriptContext.WorldModel; m_scriptFactory = scriptFactory; m_caption = caption; m_callbackScript = callbackScript; }
/// <summary> /// </summary> public InterpretedFunction(String name, IParameter[] params_Renamed, IFunction[] func, IParameter[][] functionParams) { InitBlock(); this.name = name; inputParams = params_Renamed; internalFunction = func; this.functionParams = functionParams; }
public SetFieldScript(ScriptContext scriptContext, IFunction<Element> obj, IFunction<string> field, IFunction<object> value) { m_scriptContext = scriptContext; m_worldModel = scriptContext.WorldModel; m_obj = obj; m_field = field; m_value = value; }
private bool DrawLine(double x1, double x2, double formerY, double y, Brush color, IFunction function) { LineParameters lineparams = new LineParameters(x1, x2, formerY, y, color, function); BoolWrapper result = this.m_Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, m_DrawLine, lineparams) as BoolWrapper; return (result != null) ? result.BoolValue : false; }
public ForScript(ScriptContext scriptContext, IScriptFactory scriptFactory, string variable, IFunction <int> from, IFunction <int> to, IFunction <int> step, IScript loopScript) : this(scriptContext, scriptFactory, variable, from, to, loopScript) { m_step = step; }
public MealyAutomaton(IFunction ff, IFunction gg) : base(ff, gg) { }
public bool Equals(IFunction other) { return(this.CompareTo(other) == 0); }
public Expotential(IFunction operand) : base() { this.Operand = operand; }
public static double FunctionEvaluate(IFunction func, Vector x) { return(func.Evaluate(x)); }
private void BtnMCLaurin_Click(object sender, EventArgs e) { double result = 0; zoomValue = trackBar1.Value; double[] coefficient = new double[8]; double Y1 = 0; double Y2 = 0; float X1 = 0; float X2 = 0; var Colors = new List <Color> { Color.Yellow, Color.Orange, Color.Pink, Color.Red, Color.Purple, Color.Blue, Color.Brown, Color.Black }; try { for (int i = 0; i <= 7; i++) // added coefficient of the taylor series in the array { if (i == 0) { result = root.Evaluate(0); coefficient[i] = result; } else { root = root.derivative(); result = (root.Evaluate(0) / Factorial(i)); if (double.Equals(double.NaN, result)) { result = 0; } else { coefficient[i] = result; } } } //DrawBinaryTreeMCLauran(root); DrawGridLines(); for (int i = 7; i >= 0; i--) { string equation = ""; equation += coefficient[i].ToString() + " * x^ " + (i).ToString(); Console.WriteLine(equation); } for (float j = -200; j < (pictureBox1.Height) / 2; j += 0.01f) { for (int i = 0; i <= 7; i++) { if (i == 0) { Y1 = coefficient[0]; Y2 = coefficient[0]; } else { Y1 += coefficient[i] * Math.Pow(j, i); Y2 += coefficient[i] * Math.Pow((j + 0.01f), i); } if (Y1 <= pictureBox1.Height / 2 && Y2 <= pictureBox1.Height / 2 && Y1 >= -200 && Y2 >= -200) { g.DrawLine(new Pen(Colors[i], 2f), (zoomValue * j) + orgX, (float)((-1) * Y1 * zoomValue + orgY), (zoomValue * j) + orgX + 0.1f, (float)((-1) * Y2 * zoomValue + orgY)); } } Y1 = ((-1) * Y1 * zoomValue) + orgY; Y2 = ((-1) * Y2 * zoomValue) + orgY; X1 = (zoomValue * j) + orgX; X2 = (zoomValue * j) + orgX + 0.01f; if (Y1 <= pictureBox1.Height && Y2 <= pictureBox1.Height && Y1 >= 0 && Y2 >= 0) { g.DrawLine(new Pen(Colors[6], 2f), X1, (float)Y1, X2, (float)Y2); } Y1 = Y2 = 0; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void Define(IFunction function) { this.functions.Add(function.Name, function); }
public override bool Equals(object obj) { IFunction other = obj as IFunction; return(other != null && this.Equals(other)); }
private void WriteInitSequence(IFunction function) { this.WriteOperation("Init", function, nameof(function.Description)); this.WriteOperation("Init", function, nameof(function.Arguments)); this.WriteOperation("Init", function, nameof(function.Result)); }
/// <summary> /// This is a javascript application. /// </summary> /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param> public Application(IApp page) { Console.WriteLine("Application ctor"); if (page != null) { if (page.Content != null) { if (page.Content.childNodes.Length == 0) { var f = new IFunction(""); f.apply(null); ApplicationWebService service = new ApplicationWebService(); ApplicationSprite sprite = new ApplicationSprite(); sprite.AutoSizeSpriteTo(page.ContentSize); sprite.AttachSpriteTo(page.Content); //Console.WriteLine("init... WhenReady?"); // a.__out_MethodInterface.MgAABkE_bRDa_ancxRw7JDdQ(PQAABosGVzucrRDVfJkoTA(a, b)); //sprite.WhenReady( // delegate // { // Console.WriteLine("init... Ready!"); // } //); return; } } } Console.WriteLine("looking for myself..."); //Native.Window.alert("now what?"); //Action yield = delegate //{ // Console.WriteLine("looking for myself... done!"); //}; Native.window.requestAnimationFrame += delegate { Native.Document.getElementsByTagName("embed").WithEach( e => { var embed = (IHTMLEmbedFlash)e; try { // this is a hack //var sprite = new ApplicationSprite(); //object sprite_object = sprite; //dynamic a = sprite_object; //a.__InternalElement = embed; //var sprite = (ApplicationSprite)(object)embed; Console.WriteLine("looking for myself... WhenReady?"); Initialize( args => { embed.CallFunction("WhenReady", new[] { args }); } ); //sprite.WhenReady(yield); } catch { } } ); }; }
public virtual int analyze(IRule rule) { int result = Analysis_Fields.VALIDATION_PASSED; error = new ErrorSummary(); warning = new WarningSummary(); checkForModule(rule); ICondition[] cnds = rule.Conditions; for (int idx = 0; idx < cnds.Length; idx++) { ICondition cnd = cnds[idx]; if (cnd is ObjectCondition) { ObjectCondition oc = (ObjectCondition)cnd; Deftemplate dft = oc.Deftemplate; if (dft != null) { IConstraint[] cntrs = oc.Constraints; for (int idy = 0; idy < cntrs.Length; idy++) { IConstraint cons = cntrs[idy]; if (cons is LiteralConstraint) { Slot sl = dft.getSlot(cons.Name); if (sl == null) { error.addMessage(INVALID_SLOT + " " + cons.Name + " slot does not exist."); result = Analysis_Fields.VALIDATION_FAILED; } } else if (cons is BoundConstraint) { BoundConstraint bc = (BoundConstraint)cons; if (!bc.isObjectBinding) { Slot sl = dft.getSlot(bc.Name); if (sl == null) { error.addMessage(INVALID_SLOT + " " + cons.Name + " slot does not exist."); result = Analysis_Fields.VALIDATION_FAILED; } } } else if (cons is PredicateConstraint) { PredicateConstraint pc = (PredicateConstraint)cons; IFunction f = engine.findFunction(pc.FunctionName); if (f == null) { addInvalidFunctionError(pc.FunctionName); } } } } else { error.addMessage(INVALID_TEMPLATE + " " + oc.TemplateName + " template does not exist."); result = Analysis_Fields.VALIDATION_FAILED; } } else if (cnd is TestCondition) { TestCondition tc = (TestCondition)cnd; if (tc.Function == null) { error.addMessage(NO_FUNCTION); result = Analysis_Fields.VALIDATION_FAILED; } else { IFunction f = tc.Function; if (engine.findFunction(f.Name) == null) { addInvalidFunctionError(f.Name); result = Analysis_Fields.VALIDATION_FAILED; } } } else if (cnd is ExistCondition) { } } // now we check the Right-hand side IAction[] acts = rule.Actions; for (int idx = 0; idx < acts.Length; idx++) { IAction act = acts[idx]; if (act is FunctionAction) { FunctionAction fa = (FunctionAction)act; if (engine.findFunction(fa.FunctionName) == null) { addInvalidFunctionError(fa.FunctionName); result = Analysis_Fields.VALIDATION_FAILED; } } } return(result); }
bool?IType.SatisfiedBy(IFunction value, CompilationContext info) => value is Error ? (bool?)null : (value == this || value.Inputs?.Length > 0);
public CreateExitScript(ScriptContext scriptContext, IFunction <string> name, IFunction <Element> from, IFunction <Element> to) { m_scriptContext = scriptContext; m_worldModel = scriptContext.WorldModel; m_name = name; m_from = from; m_to = to; }
public int CompareTo(IFunction other) { return(object.ReferenceEquals(this, other) ? 0 : 1); }
public CreateExitScript(ScriptContext scriptContext, IFunction <string> name, IFunction <Element> from, IFunction <Element> to, IFunction <string> initialType, IFunction <string> id) : this(scriptContext, name, from, to, initialType) { m_id = id; }
public CreateScript(ScriptContext scriptContext, IFunction <string> expr) { m_scriptContext = scriptContext; m_worldModel = scriptContext.WorldModel; m_expr = expr; }
public override void SetParameterInternal(int index, object value) { m_expr = new Expression <string>((string)value, m_scriptContext); }
protected IOperand GetOperand <T>() where T : IConvertible { string text = ""; IOperand output = null; scanner.SkipWhitespace(); if (scanner.Current == '-') { // convert leading - to "-1" if it precedes a variable, otherwise // just add it to the output stream scanner.Next(); if (scanner.Finished) { throw new ArgumentException("Unexpected end of string found, expected an operand (a number or variable name)"); } if (CharacterData.IsType(scanner.Current, CharacterType.Number)) { text += "-"; } else { output = new Literal <T>(-1); } } else if (scanner.Current == '+') { // ignore leading + scanner.Next(); } if (output == null) { if (scanner.Info.Numeric) { text += scanner.Get(MatchFunctions.Number()); double num; if (Double.TryParse(text, out num)) { output = IsTyped ? new Literal <T>(num) : new Literal(num); } else { throw new InvalidCastException("Unable to parse number from '" + text + "'"); } } else if (scanner.Info.Alpha) { text += scanner.GetAlpha(); if (scanner.CurrentOrEmpty == "(") { IFunction func = Utils.GetFunction <T>(text); var inner = scanner.ExpectBoundedBy('(', true).ToNewScanner("{0},"); while (!inner.Finished) { string parm = inner.Get(MatchFunctions.BoundedBy(boundEnd: ",")); EquationParserEngine innerParser = new EquationParserEngine(); IOperand innerOperand = innerParser.Parse <T>(parm); func.AddOperand(innerOperand); } CacheVariables(func); output = func; } else { IVariable var = GetVariable <T>(text); output = var; } } else if (scanner.Current == '(') { string inner = scanner.Get(MatchFunctions.BoundedBy("(")); var parser = new EquationParserEngine(); parser.Parse <T>(inner); output = parser.Clause; CacheVariables(output); } else { throw new ArgumentException("Unexpected character '" + scanner.Match + "' found, expected an operand (a number or variable name)"); } } scanner.SkipWhitespace(); ParseEnd = scanner.Finished; return(output); }
public CreateScript(ScriptContext scriptContext, IFunction <string> expr, IFunction <string> type) : this(scriptContext, expr) { m_type = type; }
public ForScript(ScriptContext scriptContext, IScriptFactory scriptFactory, string variable, IFunction <int> from, IFunction <int> to, IScript loopScript) { m_scriptContext = scriptContext; m_worldModel = scriptContext.WorldModel; m_scriptFactory = scriptFactory; m_variable = variable; m_from = from; m_to = to; m_loopScript = loopScript; }
public static ImageRaster4D <ElementType> LoadImageRaster4DBitmap <ElementType>(string file_path, IFunction <Color, ElementType> color_converter) { Bitmap image_color = new Bitmap(file_path); FrameDimension frame_dimension = GetFrameDimension(image_color); Raster4DInteger raster = new Raster4DInteger(image_color.Width, image_color.Height, image_color.GetFrameCount(frame_dimension), 1); ElementType[] image_array = new ElementType[raster.ElementCount]; for (int index_z = 0; index_z < raster.Size2; index_z++) { image_color.SelectActiveFrame(frame_dimension, index_z); for (int index_y = 0; index_y < raster.Size1; index_y++) { for (int index_x = 0; index_x < raster.Size0; index_x++) { image_array[raster.GetElementIndex(index_x, index_y, index_z, 0)] = color_converter.Compute(image_color.GetPixel(index_x, index_y)); } } } return(new ImageRaster4D <ElementType>(raster, image_array, false)); }
public FilteredArrayInfo(IFunction variable, IList <IVariableFilter> filters) { this.filters = filters; this.variable = variable; this.rank = variable.Arguments.Count; }
public static IImageRaster2D <ElementType> Convert <ElementType>(String path, IFunction <Color, ElementType> color_converter) { // Open a Stream and decode a bitmap image Bitmap image_color = new Bitmap(path); int element_count = image_color.Width * image_color.Height; ElementType[] image_array = new ElementType[element_count]; IRaster2DInteger raster = new Raster2DInteger(image_color.Width, image_color.Height); for (int index_y = 0; index_y < image_color.Height; index_y++) { for (int index_x = 0; index_x < image_color.Width; index_x++) { image_array[raster.GetElementIndex(index_x, index_y)] = color_converter.Compute(image_color.GetPixel(index_x, index_y)); } } return(new ImageRaster2D <ElementType>(raster, image_array, false)); }
internal FunctionRuntimeTreeNode(IFunction function, List <BaseParameterRuntimeTreeNode> parameters) { _function = function; this.Parameters = parameters; }
public SGD(IFunction func, R learningRate) : base(func) { this.LearningRate = learningRate; }
/// <exclude /> public FunctionRuntimeTreeNode(IFunction function) { _function = function; this.Parameters = new List <BaseParameterRuntimeTreeNode>(); }
public static NdArray <Real> SingleInputForward(NdArray <Real> x, NdArray <Real> weight, NdArray <Real> bias, ComputeKernel forwardKernel, IFunction <Real> linear) { int outputCount = weight.Shape[0]; int inputCount = weight.Shape[1]; Real[] y = bias == null ? new Real[outputCount * x.BatchCount] : LinearFunc.GetBiasedValue(x.BatchCount, outputCount, bias.Data); using (ComputeBuffer <Real> gpuX = new ComputeBuffer <Real>(OpenCL.Context, ComputeMemoryFlags.ReadOnly | ComputeMemoryFlags.UseHostPointer, x.Data)) using (ComputeBuffer <Real> gpuW = new ComputeBuffer <Real>(OpenCL.Context, ComputeMemoryFlags.ReadOnly | ComputeMemoryFlags.UseHostPointer, weight.Data)) using (ComputeBuffer <Real> gpuY = new ComputeBuffer <Real>(OpenCL.Context, ComputeMemoryFlags.ReadWrite | ComputeMemoryFlags.UseHostPointer, y)) { forwardKernel.SetMemoryArgument(0, gpuX); forwardKernel.SetMemoryArgument(1, gpuW); forwardKernel.SetMemoryArgument(2, gpuY); forwardKernel.SetValueArgument(3, outputCount); forwardKernel.SetValueArgument(4, inputCount); OpenCL.CommandQueue.Execute ( forwardKernel, null, new long[] { outputCount, x.BatchCount }, null, null ); OpenCL.CommandQueue.Finish(); OpenCL.CommandQueue.ReadFromBuffer(gpuY, ref y, true, null); } return(NdArray.Convert(y, new[] { outputCount }, x.BatchCount, linear)); }
private bool ProcessWidgets(bool processPost, bool showValidationErrors = false, bool ignoreValidationErrors = false) { XElement functionMarkup = XElement.Parse(FunctionMarkupInState); string functionName = (string)functionMarkup.Attribute("name"); IFunction function = FunctionFacade.GetFunction(functionName); if (function.ParameterProfiles.All(p => p.WidgetFunction == null)) { plhNoParameters.Visible = true; return(true); } var bindings = new Dictionary <string, object>(); var parameterNodes = FunctionMarkupHelper.GetParameterNodes(functionMarkup); foreach (var parameterProfile in function.ParameterProfiles) { object parameterValue; XElement parameterNode; if (parameterNodes.TryGetValue(parameterProfile.Name, out parameterNode)) { parameterValue = FunctionMarkupHelper.GetParameterValue(parameterNode, parameterProfile); } else { parameterValue = parameterProfile.GetDefaultValue(); } if (parameterProfile.Type.IsLazyGenericType() && parameterValue != null) { parameterValue = parameterProfile.Type.GetProperty("Value").GetGetMethod().Invoke(parameterValue, null); } bindings.Add(parameterProfile.Name, parameterValue); } var formTreeCompiler = FunctionUiHelper.BuildWidgetForParameters( function.ParameterProfiles.Where(p => !p.HideInSimpleView || (p.IsRequired && (!bindings.ContainsKey(p.Name) || bindings[p.Name] == null))), bindings, "BasicView", "", WebManagementChannel.Identifier); var webUiControl = (IWebUiControl)formTreeCompiler.UiControl; var webControl = webUiControl.BuildWebControl(); BasicContentPanel.Controls.Add(webControl); if (!processPost) { webUiControl.InitializeViewState(); return(true); } // Loading control's post data LoadPostBackData(webControl); var validationErrors = formTreeCompiler.SaveAndValidateControlProperties(); if (!ignoreValidationErrors) { // Validating required parameters foreach (var parameterProfile in function.ParameterProfiles) { if (!validationErrors.ContainsKey(parameterProfile.Name) && parameterProfile.IsRequired && parameterProfile.WidgetFunction != null && (!bindings.ContainsKey(parameterProfile.Name) || bindings[parameterProfile.Name] == null)) { validationErrors.Add(parameterProfile.Name, new Exception( StringResourceSystemFacade.GetString("Composite.Management", "Validation.RequiredField"))); } } if (validationErrors.Any()) { if (showValidationErrors) { ShowServerValidationErrors(formTreeCompiler, validationErrors); } return(false); } } foreach (var parameterProfile in function.ParameterProfiles) { XElement parameterNode; parameterNodes.TryGetValue(parameterProfile.Name, out parameterNode); object value = bindings[parameterProfile.Name]; if (!parameterProfile.IsRequired) { object defaultValue = parameterProfile.GetDefaultValue(); if (value == defaultValue || (value != null && value.Equals(defaultValue)) || (value is XNode && defaultValue is XNode && XElement.DeepEquals(value as XNode, defaultValue as XNode)) || parameterProfile.WidgetFunction == null) { if (parameterNode != null) { parameterNode.Remove(); } continue; } } FunctionMarkupHelper.SetParameterValue(functionMarkup, parameterProfile, value); } FunctionMarkupInState = functionMarkup.ToString(); return(true); }
public void Setup() { this.id = new IdFunction(); }