// Constructor: v is a parameter and y is a variable (0x1) public Constraints1ConstraintElement( ImIndexElement mIndexElement, IrIndexElement rIndexElement, Im m, Is s, Interfaces.Parameters.MachineOperatingRoomAssignments.Iv v, Iζ ζ, Interfaces.Variables.Iy y) { Expression LHS = Expression.Sum( s.Value .Select( x => y.Value[x, rIndexElement] * ζ.GetElementAtAsint( x, mIndexElement))); int RHS = m.GetM() * v.GetElementAtAsint( mIndexElement, rIndexElement); this.Value = LHS <= RHS; }
public override int GetHashCode() { unchecked { return(Im.GetHashCode() * 16777619 + Re.GetHashCode()); } }
public static UIState InitialState() { return(new UIState( new List <PopupType>(), Im.Map <int>() )); }
public void ToStringTest() { var complex = new Complex(3.1, 2.5); var exp = new Im(new ComplexNumber(complex)); Assert.Equal("im(3.1+2.5i)", exp.ToString()); }
public void ImToStringTest() { var complex = new Complex(3.1, 2.5); var exp = new Im(new ComplexNumber(complex)); Assert.Equal("im(3.1+2.5i)", exp.ToString(commoonFormatter)); }
public override int GetHashCode() { unchecked { return((Re.GetHashCode() * 397) ^ Im.GetHashCode()); } }
public void ExecuteTest1() { var complex = new Complex(3.1, 2.5); var exp = new Im(new ComplexNumber(complex)); Assert.Equal(complex.Imaginary, exp.Execute()); }
public void GetHubById_ImId_FindsImViaApi_AndIsCached() { var imId = "D123"; var userId = "U123"; var matchingIm = new Im { Id = imId, User = userId }; var otherIm = new Im { Id = "D456" }; _api.Im.List().Returns(new[] { otherIm, matchingIm }); var expectedIm = new Im(); _api.Im.Open(userId, true).Returns(new ImResponse { Channel = expectedIm }); _sut.GetHubById(imId) .ShouldComplete() .And.ShouldBe(expectedIm); _sut.GetHubById(imId) .ShouldComplete() .And.ShouldBe(expectedIm); _api.Im.Received(1).List(); _api.Im.Received(1).Open(userId, true); }
// v and y are both variables public IConstraints1ConstraintElement Create( ImIndexElement mIndexElement, IrIndexElement rIndexElement, Im m, Is s, Iζ ζ, Iv v, Iy y) { IConstraints1ConstraintElement constraintElement = null; try { constraintElement = new Constraints1ConstraintElement( mIndexElement, rIndexElement, m, s, ζ, v, y); } catch (Exception exception) { this.Log.Error( exception.Message, exception); } return(constraintElement); }
public void GetImByName_FindsImWithMatchingUserName_AndCaches() { var matchingUser = new User { Id = "U1", Name = "foo" }; var otherUser = new User { Id = "U2", Name = "bar" }; _api.Users.List().Returns(new UserListResponse { Members = { otherUser, matchingUser } }); var expectedIm = new Im { Id = "D123", User = matchingUser.Id }; _api.Im.Open(matchingUser.Id, true).Returns(new ImResponse { Channel = expectedIm }); _sut.GetImByName("@foo") .ShouldComplete() .And.ShouldBe(expectedIm); _sut.GetImByName("foo") .ShouldComplete() .And.ShouldBe(expectedIm); _api.Users.Received(1).List(); _api.Im.ReceivedWithAnyArgs(1).Open(Arg.Any <string>()); }
private void button1_Click(object sender, EventArgs e) { // povikuvanje na site broevi pomali od 0 const double small = 1E-15; double Re; double Im; //presmetka na koren List <Complex> Roots = SolveCubic(Coeff.A, Coeff.B, Coeff.C, Coeff.D); Re = Math.Abs(Roots[0].Real) < small ? 0.0 : Roots[0].Real; Im = Math.Abs(Roots[0].Imaginary) < small ? 0.0 : Roots[0].Imaginary; X1RealTxb.Text = Re.ToString(); X1ImagTxb.Text = Im.ToString(); Re = Math.Abs(Roots[1].Real) < small ? 0.0 : Roots[1].Real; Im = Math.Abs(Roots[1].Imaginary) < small ? 0.0 : Roots[1].Imaginary; X2RealTxb.Text = Re.ToString(); X2ImagTxb.Text = Im.ToString(); Re = Math.Abs(Roots[2].Real) < small ? 0.0 : Roots[2].Real; Im = Math.Abs(Roots[2].Imaginary) < small ? 0.0 : Roots[2].Imaginary; X3RealTxb.Text = Re.ToString(); X3ImagTxb.Text = Im.ToString(); }
public void CloneTest() { var exp = new Im(new ComplexNumber(new Complex(2, 2))); var clone = exp.Clone(); Assert.Equal(exp, clone); }
// TODO think about how to improve performance public override ImList <RenderCommand> Handle(EventParameters eventParameters) { var transformedParameters = TransformEventParameters(eventParameters); var renderCommandList = Origin.Handle(transformedParameters); return(Im.Transform(TransformPackage, renderCommandList)); }
// Constructor: v is a variable and y is a parameter (1x0) public Constraints1ConstraintElement( ImIndexElement mIndexElement, IrIndexElement rIndexElement, Im m, Is s, Interfaces.Parameters.SurgeonOperatingRoomAssignments.Iy y, Iζ ζ, Interfaces.Variables.Iv v) { int LHS = s.Value .Select( x => y.GetElementAtAsint( x, rIndexElement) * ζ.GetElementAtAsint( x, mIndexElement)) .Sum(); Expression RHS = m.GetM() * v.Value[mIndexElement, rIndexElement]; this.Value = LHS <= RHS; }
// v is a parameter and y is a variable public IConstraints1ConstraintElement Create( ImIndexElement mIndexElement, IrIndexElement rIndexElement, Im m, Is s, Interfaces.Parameters.MachineOperatingRoomAssignments.Iv v, Iζ ζ, Interfaces.Variables.Iy y) { IConstraints1ConstraintElement constraintElement = null; try { constraintElement = new Constraints1ConstraintElement( mIndexElement, rIndexElement, m, s, v, ζ, y); } catch (Exception exception) { this.Log.Error( exception.Message, exception); } return(constraintElement); }
public override int GetHashCode() { unchecked { // ReSharper disable once NonReadonlyMemberInGetHashCode return((Re.GetHashCode() * 397) ^ Im.GetHashCode()); } }
public static State UnpackNewestEventArchive(ImList <EventArchive> eventArchives, State state) { return(state & Store.UpdateGameState(eventArchives[0].Snapshot) & Store.UpdateEventStoreList((Store.GetEventStoreList(state) * eventArchives[0].Archive) & Im.Sort) & Store.UpdateEventArchives(Im.Tail(eventArchives)) ); }
public bool Equals(ComplexNumber cnum) { if(cnum is null) { return false; } return Re.Equals(cnum.Re) && Im.Equals(cnum.Im); }
public static SlackChatHub ToChatHub(this Im im, SlackUser[] users) { SlackUser user = users.FirstOrDefault(x => x.Id == im.User); return(new SlackChatHub { Id = im.Id, Name = "@" + (user == null ? im.User : user.Name), Type = SlackChatHubType.DM }); }
public static State OverlayOnEventStoreList(ImList <Event> eventList, State state) { var eventStoreList = Store.GetEventStoreList(state); return(Store.UpdateEventStoreList( eventList & Im.Overlay((evnt1, evnt2) => evnt1.Equals(evnt2), eventStoreList) & Im.Sort , state )); }
// Constructor: v and y are both parameters (0x0) public Constraints1ConstraintElement( ImIndexElement mIndexElement, IrIndexElement rIndexElement, Im m, Is s, Interfaces.Parameters.MachineOperatingRoomAssignments.Iv v, Interfaces.Parameters.SurgeonOperatingRoomAssignments.Iy y, Iζ ζ) { // Not needed }
public SlackChatHub GetChatHub(Im im, string user) { var dm = new SlackChatHub { Id = im.Id, Name = "@" + (string.IsNullOrEmpty(user) ? im.User : user), Type = SlackChatHubType.DM }; return(dm); }
static void Main() { Action1 <object> d1 = n => { }; Action1 <string> d2 = d1; // stringからobjectの変換はコンパイル不可 // d3 = d4; ISample <Sub> s = new Im(); ISample <Base> b = s; // BaseらSubの変換はコンパイル不可 // s = b; }
public override string ToString() { string result = Re.ToString(); if (Im < 0) { result += (Im.ToString() + "i"); } else { result += ("+" + Im.ToString() + "i"); } return(result); }
public SlackApi(string token, string apiUrl = "https://slack.com/api") { Token = token; Url = apiUrl; var client = new Client(token, Url); Channels = new Channels(client); Groups = new Groups(client); Im = new Im(client); Mpim = new Mpim(client); Users = new Users(client); Chat = new Chat(client); Reactions = new Reactions(client); }
public void GetHubById_ImId_ReturnsImInfoFromApi_AndIsCached() { var imId = "D123"; var expectedIm = new Im(); _api.Conversations.OpenAndReturnInfo(imId).Returns(new ImResponse { Channel = expectedIm }); _sut.GetHubById(imId) .ShouldComplete() .And.ShouldBe(expectedIm); _sut.GetHubById(imId) .ShouldComplete() .And.ShouldBe(expectedIm); _api.Conversations.Received(1).OpenAndReturnInfo(imId); }
public void GetImByUserId_OpensImWithUser_AndCaches() { var expectedIm = new Im { Id = "D123", User = "******" }; _api.Im.Open(expectedIm.User, true).Returns(new ImResponse { Channel = expectedIm }); _sut.GetImByUserId(expectedIm.User) .ShouldComplete() .And.ShouldBe(expectedIm); _sut.GetImByUserId(expectedIm.User) .ShouldComplete() .And.ShouldBe(expectedIm); _api.Im.Received(1).Open(expectedIm.User, true); }
public static void WriteIm(this XmlWriter writer, Im im) { if (im != null) { gdWriteStartElement(writer, "im"); writer.WriteAttributeString("address", im.Address); gdWriteAttributeString(writer, "label", im.Label); gdWriteAttributeString(writer, "rel", im.Rel); gdWriteAttributeString(writer, "protocol", im.Protocol); gdWriteAttributeString(writer, "primary", im.Primary.ToString()); writer.WriteEndElement(); } }
public void GetIms_FetchesOpenIms_AndCaches() { var im1 = new Im { Id = "D1" }; var im2 = new Im { Id = "D2" }; _api.Im.List().Returns(new[] { im1, im2 }); _sut.GetIms() .ShouldComplete() .And.ShouldMatch(new[] { im1, im2 }); _sut.GetIms() .ShouldComplete() .And.ShouldMatch(new[] { im1, im2 }); _api.Im.Received(1).List(); }
public Im Create( ImmutableList <ImIndexElement> value) { Im index = null; try { index = new m( value); } catch (Exception exception) { this.Log.Error( exception.Message, exception); } return(index); }
public void GetHubByName_UserName_FindsImWithMatchingUser() { var matchingUser = new User { Id = "U1", Name = "foo" }; var otherUser = new User { Id = "U2", Name = "bar" }; _api.Users.List().Returns(new UserListResponse { Members = { otherUser, matchingUser } }); var expectedIm = new Im { Id = "D123" }; _api.Im.Open(matchingUser.Id, true).Returns(new ImResponse { Channel = expectedIm }); _sut.GetHubByName("@foo") .ShouldComplete() .And.ShouldBe(expectedIm); }
public void ImTest() { var tokens = new List<IToken> { new FunctionToken(Functions.Im, 1), new SymbolToken(Symbols.OpenBracket), new ComplexNumberToken(new Complex(3, -2)), new SymbolToken(Symbols.CloseBracket) }; var exp = parser.Parse(tokens); var expected = new Im(new ComplexNumber(new Complex(3, -2))); Assert.Equal(expected, exp); }
/// <summary> /// Creates an expression object from <see cref="FunctionToken"/>. /// </summary> /// <param name="token">The function token.</param> /// <returns>An expression.</returns> protected virtual IExpression CreateFunction(FunctionToken token) { IExpression exp; switch (token.Function) { case Functions.Add: exp = new Add(); break; case Functions.Sub: exp = new Sub(); break; case Functions.Mul: exp = new Mul(); break; case Functions.Div: exp = new Div(); break; case Functions.Pow: exp = new Pow(); break; case Functions.Absolute: exp = new Abs(); break; case Functions.Sine: exp = new Sin(); break; case Functions.Cosine: exp = new Cos(); break; case Functions.Tangent: exp = new Tan(); break; case Functions.Cotangent: exp = new Cot(); break; case Functions.Secant: exp = new Sec(); break; case Functions.Cosecant: exp = new Csc(); break; case Functions.Arcsine: exp = new Arcsin(); break; case Functions.Arccosine: exp = new Arccos(); break; case Functions.Arctangent: exp = new Arctan(); break; case Functions.Arccotangent: exp = new Arccot(); break; case Functions.Arcsecant: exp = new Arcsec(); break; case Functions.Arccosecant: exp = new Arccsc(); break; case Functions.Sqrt: exp = new Sqrt(); break; case Functions.Root: exp = new Root(); break; case Functions.Ln: exp = new Ln(); break; case Functions.Lg: exp = new Lg(); break; case Functions.Lb: exp = new Lb(); break; case Functions.Log: exp = new Log(); break; case Functions.Sineh: exp = new Sinh(); break; case Functions.Cosineh: exp = new Cosh(); break; case Functions.Tangenth: exp = new Tanh(); break; case Functions.Cotangenth: exp = new Coth(); break; case Functions.Secanth: exp = new Sech(); break; case Functions.Cosecanth: exp = new Csch(); break; case Functions.Arsineh: exp = new Arsinh(); break; case Functions.Arcosineh: exp = new Arcosh(); break; case Functions.Artangenth: exp = new Artanh(); break; case Functions.Arcotangenth: exp = new Arcoth(); break; case Functions.Arsecanth: exp = new Arsech(); break; case Functions.Arcosecanth: exp = new Arcsch(); break; case Functions.Exp: exp = new Exp(); break; case Functions.GCD: exp = new GCD(); break; case Functions.LCM: exp = new LCM(); break; case Functions.Factorial: exp = new Fact(); break; case Functions.Sum: exp = new Sum(); break; case Functions.Product: exp = new Product(); break; case Functions.Round: exp = new Round(); break; case Functions.Floor: exp = new Floor(); break; case Functions.Ceil: exp = new Ceil(); break; case Functions.Derivative: exp = new Derivative(); break; case Functions.Simplify: exp = new Simplify(); break; case Functions.Del: exp = new Del(); break; case Functions.Define: exp = new Define(); break; case Functions.Vector: exp = new Vector(); break; case Functions.Matrix: exp = new Matrix(); break; case Functions.Transpose: exp = new Transpose(); break; case Functions.Determinant: exp = new Determinant(); break; case Functions.Inverse: exp = new Inverse(); break; case Functions.If: exp = new If(); break; case Functions.For: exp = new For(); break; case Functions.While: exp = new While(); break; case Functions.Undefine: exp = new Undefine(); break; case Functions.Im: exp = new Im(); break; case Functions.Re: exp = new Re(); break; case Functions.Phase: exp = new Phase(); break; case Functions.Conjugate: exp = new Conjugate(); break; case Functions.Reciprocal: exp = new Reciprocal(); break; case Functions.Min: exp = new Min(); break; case Functions.Max: exp = new Max(); break; case Functions.Avg: exp = new Avg(); break; case Functions.Count: exp = new Count(); break; case Functions.Var: exp = new Var(); break; case Functions.Varp: exp = new Varp(); break; case Functions.Stdev: exp = new Stdev(); break; case Functions.Stdevp: exp = new Stdevp(); break; default: exp = null; break; } var diff = exp as DifferentParametersExpression; if (diff != null) diff.ParametersCount = token.CountOfParams; return exp; }
void ICQAPP__onMessage(Im im) { cmd.StandardInput.WriteLine(im.msg); uin = im.uin; }