Search Results

Search found 1803 results on 73 pages for 'pi calculation'.

Page 52/73 | < Previous Page | 48 49 50 51 52 53 54 55 56 57 58 59  | Next Page >

  • Trigger the change event of a textbox in jQuery

    - by Danny Chen
    I have an asp:TextBox with asp:RegularExpressionValidator to validate if it's a number. Obviously an onchange event will be attached to this textbox while rendering. Also I add a change event at $(document).ready to make some calculation when the value is changed. <asp:TextBox id="myText" runat="server" /> <asp:regularexpressionvalidator id="myRev" ControlToValidate="myText" runat="server">*</asp:regularexpressionvalidator> $(document).ready(function(){ $('[id$=myText]').bind('change',function(){ //do something }).change(); //force the change event at the very beginning }); My function will be executed later than the .net generated js because of the register time. But the .net js throws an error. I traced in the js: function ValidatorOnChange(event) { ... } and found that all of event.fromElement,event.toElement,event.srcElement are null which causes the exception. Did I do something wrong? Any solutions? Thanks.

    Read the article

  • Planning a competition

    - by Jérôme
    I need to produce the schedule of a sport-event. There are 30 teams. Each team has to play 8 matches. This means that it is not possible for each team to compete again all other teams, but I need to avoid that two team compete more than once against each other. My idea was to generate all possible matches (for 30 teams: (30*29)/2 = 435 matches) and select from this list 120 matches (8 match for each team: 8 * 30 / 2 = 120 matches). This is where I'm having a hard time: how can I select these 120 matches? I tried some simple solutions (take first match of the list, then the last, and so on) but they don't seem to work with 30 teams. I also tried to generate all possible match combination and find which one is working but with 30 team, this is too much calculation time. Is there an existing algorithm that I could implement?

    Read the article

  • What's the best way of using a pair (triple, etc) of values as one value in C#?

    - by Yacoder
    That is, I'd like to have a tuple of values. The use case on my mind: Dictionary<Pair<string, int>, object> or Dictionary<Triple<string, int, int>, object> Are there built-in types like Pair or Triple? Or what's the best way of implementing it? Update There are some general-purpose tuples implementations described in the answers, but for tuples used as keys in dictionaries you should additionaly verify correct calculation of the hash code. Some more info on that in another question. Update 2 I guess it is also worth reminding, that when you use some value as a key in dictionary, it should be immutable.

    Read the article

  • need to count the frequency of each terms inside a document

    - by Wai Loon II
    hi, i need to calculate the frequency of all the terms inside a document. How can i do that ? i do not ask for codes. I am just asking for guidance. Actually i am doing some similarity calculation between a document and query. I have calculated the term frequency for the query. But i do not know how to calculate the tern frequency for EACH words inside a document. Can anyone guide me ? Thank you for your attention.

    Read the article

  • What grid distributed computing frameworks are currently favoured for trading systems

    - by Rich
    There seems to a quite a few grid computing frameworks out there, but which ones are actually being used to any great extent by the investment banks for purposes of low latency distributing calculation? I'd be interested to hear answers covering both windows,Linux and cross platform. Also, what RPC mechanisms seem to be favoured most? I've heard that for reason of low latency and speed, the calculations themselves are quite often written in C++/C as calculations running on VMs are several orders of magnitude slower than native code. Does this seem to be a common scenario in practice? e.g distributed .NET grid framework running calculations written in native c++/c?

    Read the article

  • Any better algorithm possible here?

    - by Cupidvogel
    I am trying to solve this problem in Python. Noting that only the first kiss requires the alternation, any kiss that is not a part of the chain due to the first kiss can very well have a hug on the 2nd next person, this is the code I have come up with. This is just a simple mathematical calculation, no looping, no iteration, nothing. But still I am getting a timed-out message. Any means to optimize it? import psyco psyco.full() testcase = int(raw_input()) for i in xrange(0,testcase): n = int(raw_input()) if n%2: m = n/2; ans = 2 + 4*(2**m-1); ans = ans%1000000007; print ans else: m = n/2 - 1 ans = 2 + 2**(n/2) + 4*(2**m-1); ans = ans%1000000007 print ans

    Read the article

  • Why does get_posts() return only 5 matching posts, when it should return 9?

    - by Scott B
    global $post; $cat1=get_cat_ID('test1'); $cat2=get_cat_ID('test2'); $myrecentposts = get_posts(array('post_not_in' => get_option('sticky_posts'), 'cat' => "-$cat1,-$cat2",'showposts' => 5)); $myrecentposts2 = get_posts(array('post_not_in' => get_option('sticky_posts'), 'cat' => "-$cat1,-$cat2")); $myrecentpostscount = count($myrecentposts2); echo $myrecentpostscount; The value of the echo is 5 (the correct value should be 9). The only way I can get it to return the correct value for the post count is to change the $myrecentposts2 calculation as follows... $myrecentposts2 = get_posts(array('post_not_in' => get_option('sticky_posts'), 'cat' => "-$cat1,-$cat2",'showposts' => 999));

    Read the article

  • php smarty not passing to browser unless logged in.

    - by Kyle Sevenoaks
    I'm not the best at understanding these things with php and smarty, but this is really annoying. On: http://www.euroworker.no/order, there is meant to be a display of the amount of tax included in the price like: Tax (25%): 772,- Totalt: 3861,- But unless the user has logged in or created a new account, the tax doesn't display. Here is the Smarty code: <tr id="taxtr"> <td>&nbsp;</td> <td>&nbsp;</td> {foreach $cart.taxes.$currency as $tax} <td>&nbsp;</td> <td colspan="4" class="subTotalCaption2">{$tax.name_lang}:&nbsp;</td> <td class="amount taxAmount2">{$tax.formattedAmount}&nbsp;</td> {$cart.formattedTotal.$currency {$GLOBALS.cartUpdate|@array_shift} {/foreach} </tr> I don't know about all the inner workings of this system (Livecart), but is there anything I can do or look through to make it force the calculation/display. Thanks..

    Read the article

  • Return numerical array in python

    - by khan
    Okay..this is kind of an interesting question. I have a php form through which user enters values for x and y like this: X: [1,3,4] Y: [2,4,5] These values are stored into database as varchars. From there, these are called by a python program which is supposed to use them as numerical (numpy) arrays. However, these are called as plain strings, which means that calculation can not be performed over them. Is there a way to convert them into numerical arrays before processing or is there something else which is wrong? Helpp!!

    Read the article

  • F# script to application

    - by sudaly
    I have written two small scripts, First one maintains a dictionary of current stock prices for a set of securities. I am using recursion to listen to a named pipe. Whenever there is something available on the name pipe, it updates the security price and goes right back and start listening to the pipe. The second one periodically reads the stock price of some security from the price cache of the first program and performs come calculation. But I have no idea how to make these two programs communicate. I somehow need to make my second programs start the first program and let it run in the background and get the price whenever it needs it. Can someone point me in the right direction? Thank you, -Niran

    Read the article

  • How to change FPU context in signal handler (C++/Linux)

    - by Henry Fané
    I wrote a signal handler to catch FPE errors. I need to continue execution even if this happens. I receive a ucontext_t as parameter, I can change the bad operand from 0 to another value but the FPU context is still bad and I run into an infinite loop ? Does someone already manupulate the ucontext_t structure on Linux ? I finally found a way to handle these situations by clearing the status flag of ucontext_t like this: ... const long int cFPUStatusFlag = 0x3F; aContext->uc_mcontext.fpregs->sw &= ~cFPUStatusFlag; ... 0x3F is negated to put 0 in the 6 bits of the status register of the FPU (x87). Doing this implies to check for FPE exceptions after calculation.

    Read the article

  • Format an input with Jquery?

    - by Wes
    I'm building a calculator that has a slider. Everytime I slide the bar an input box is updated with the number, the calculator passes the value and updates the calculation. So my input boxes have dollar values that can range anywhere from $0 to $10,000. Right now my boxes display 0 to 10000 and I want them to be displayed as $0 to $10,000. I'm assuming jquery would be my best route here. How do I format an input box to display values like this. Sort of like an input mask. note: users never have to type into the input box, its all controlled by the slider.

    Read the article

  • How to break up HTML documents into pages for ebook?

    - by radnoise
    For an iPhone ebook application I need to break arbitrarily long HTML documents up into pages which fit exactly on one screen. If I simply use UIWebView for this, the bottom-most lines tend to get displayed only partly: the rest disappears off the edge of the view. So I assume I would need to know how many complete lines (or characters) would be displayed by the UIWebView, given the source HTML, and then feed it exactly the right amount of data. This probably involves lots of calculation, and the user also needs to be able to change fonts and sizes. I have no idea if this is even possible, although apps like Stanza take HTML (epub) files and paginate them nicely. It's a long time since I looked at JavaScript, would that be an option worth looking at? Any suggestions very much appreciated!

    Read the article

  • SQL Function for On Balance Volume (Financial Query)

    - by CraigJSte
    I would like to create a function for On Balance Volume (SQL Function). This is too complex of a calculation for met to figure out but here is the outline of the User Defined Table Function. If someone could help me to fill in the blanks I would appreciate it. Craig CREATE FUNCTION [dbo].[GetStdDev3] (@TKR VARCHAR(10)) RETURNS @results TABLE ( dayno SMALLINT IDENTITY(1,1) PRIMARY KEY , [date] DATETIME , [obv] FLOAT ) AS BEGIN DECLARE @rowcount SMALLINT INSERT @results ([date], [obv]) // CREATE A FUNCTION FOR ON BALANCE VOLUME // On Balance Volume is the Summ of Volume for Total Periods // OBV = 1000 at Period = 0 // OBV = OBV Previous + Previous Volume if Close Previous Close // OBV = OBV Previous - Previous Volume if Close < Previous Close // OBV = OBV Previous if Close = Previous Close // The actual Value of OBV is not important so to keep the ratio low we reduce the // Total Value of Tickers by 1/10th or 1/100th // For Value of Volume = Volume * .01 if Volume < 999 // For Value of Volume = Volume * .001 If Volume = 999 FROM Tickers RETURN END This is the Tickers table [dbo].[Tickers]( [ticker] [varchar](10) NULL, [date] [datetime] NULL, [high] [float] NULL, [low] [float] NULL, [open] [float] NULL, [close] [float] NULL, [volume] [float] NULL, [time] [datetime] NULL, [change] [float] NULL )

    Read the article

  • Stored Procedure or calculations via IQueryable?

    - by Shawn Mclean
    This is a question that is based on choosing performance over design practices. If I have a method that will be executed many times a second; public static IQueryable<IPerson> InRadius(this IQueryable<IPerson> query, Coordinate center, double radius) { return (from u in query where CallHeavyMathFormula(u, center, radius) select u); } This extension method for IQueryable generates a SQL that does some heavy maths calculation (Cosine, Sine, etc). This would mean the application sends 1-2KB of sql to the server per call. I've heard of placing all application logic, in your application. I also would like to change to a database such as azure or one of those scalable databases in the future. How do I handle something like this? Should I leave it as it is now or write stored procedures? How do applications like twitter or facebook do it?

    Read the article

  • Parallel Processing Simulation in Javascript

    - by le_havre
    Hello, I'm new to JavaScript so forgive me for being a n00b. When there's intensive calculation required, it more than likely involves loops that are recursive or otherwise. Sometimes this may mean having am recursive loop that runs four functions and maybe each of those functions walks the entire DOM tree, read positions and do some math for collision detection or whatever. While the first function is walking the DOM tree, the next one will have to wait its for the first one to finish, and so forth. Instead of doing this, why not launch those loops-within-loops separately, outside the programs, and act on their calculations in another loop that runs slower because it isn't doing those calculations itself? Retarded or clever? Thanks in advance!

    Read the article

  • Balanced Search Tree Query, Asymtotic Analysis..

    - by AGeek
    Hi, The situation is as follows:- We have n number and we have print them in sorted order. We have access to balanced dictionary data structure, which supports the operations serach, insert, delete, minimum, maximum each in O(log n) time. We want to retrieve the numbers in sorted order in O(n log n) time using only the insert and in-order traversal. The answer to this is:- Sort() initialize(t) while(not EOF) read(x) insert(x,t); Traverse(t); Now the query is if we read the elements in time "n" and then traverse the elements in "log n"(in-order traversal) time,, then the total time for this algorithm (n+logn)time, according to me.. Please explain the follow up of this algorithm for the time calculation.. How it will sort the list in O(nlogn) time?? Thanks.

    Read the article

  • Assigning a previous fieldvalue to a field in the next record

    - by user2945849
    I am working on a loan amortization schedule using Access, I have created the following tables: tblMembers - autoMemberID|txtLN|txtFN|etc tblLoans - autoLoanID|numMemberID|etc tblSchedules -autoScheduleID|numLoanID|numPayment#|datDue|dblBegin|...|dblEnd tblPayments - autoPaymID|numLoanID|curAmtPaid|datPaidDate and forms: frmLoans - autoLoanID|etc sbfSchedules - numPaymID|datDue|dblBegin|...|dblEnd sbfPayments - dblAmount|datPaid I have been able to generate the schedule (using DAO recordset) clicking a btnRepaymentSchedule the challenge is when I click a btnAddPayment still on the sbfSchedules, I want the value of the dblEnd field to be the value of the next record dblBegin field! I have tried using dlookup(txtBeginBalance = Dlookup("EndBalance", _ "Schedules","[ScheduleID] = Form![Schedules]![ScheduleID]-1) but there is no effect but if I use txtBeginBalance = txtEndBalance the value of txtEndBalance is assigned to the value of txtBeginBalance of the same record (want next record). Secondly, how can I set focus to the next record if a contro(txtAmountPaid) is not null on clicking the btnAddPayment or assigning the value of a calculation when the control is 0 or null ? Thanks

    Read the article

  • Assign value to list

    - by Kenneth B
    Hello First and foremost. I'm totally new to "programming" in Excel. I'm trying to make a price calculator, that calculates the price when I use my printer. I have made some lists so it's easy to perform the calculations. Single or duplex: Singlex/Duplex Format: SRA3 / A4 / SRA3 High Gloss The idea is that if I type in an amount of 100 prints, choose SRA3 format on the list, and choose Duplex on the other list. the calculation would look like this: This is how it's calculated: Paper + (print x sides) = Price of the print job Print prices Per page (singlex or duplex): 0,6 Paper format and price: A4 reg. paper: 0,2 SRA3 High Gloss: 1,25 SRA3 reg. paper: 1 Does anyone know about this???

    Read the article

  • Binomial test in Python for very large numbers

    - by Morlock
    I need to do a binomial test in Python that allows calculation for 'n' numbers of the order of 10000. I have implemented a quick binomial_test function using scipy.misc.comb, however, it is pretty much limited around n = 1000, I guess because it reaches the biggest representable number while computing factorials or the combinatorial itself. Here is my function: from scipy.misc import comb def binomial_test(n, k): """Calculate binomial probability """ p = comb(n, k) * 0.5**k * 0.5**(n-k) return p How could I use a native python (or numpy, scipy...) function in order to calculate that binomial probability? If possible, I need scipy 0.7.2 compatible code. Many thanks!

    Read the article

  • Timezoneoffset error when daylightsaving in effect in iOS

    - by Ranjit
    friends,I am getting a date based on the calculation I have done below NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDate *expectedDate = [gregorian dateByAddingComponents:components toDate:startDate options:0]; NSTimeInterval timeZoneOffset = -[[NSTimeZone systemTimeZone] secondsFromGMTForDate:expectedDate]; NSDate *localDate = [expectedDate dateByAddingTimeInterval:(timeZoneOffset)]; NSString *date = [dateFormatter stringFromDate:localDate]; But the date goes wrong when the daylightsaving is in effect,and also the timeZoneOffset changes when the daylightsaving is in effect, but I want the same date irrespective of whether the daylight saving is in effect or no.. So friends,how shall I handle this situation,please help. Regards Ranjit

    Read the article

  • PHP Get images from a UL list

    - by benjamin shrimpton
    I have a long UL list and each LI contains an image tag, dynamically generated from SLideshowPro Director. I need to get the widths of ALL the images inside the UL to use in a CSS width calculation. I have been able to get the image width for the first item, but not all. My PHP is pretty limited, but do I have to make this list into an ARRAY first to allow me to get all the widths? And how do i do that?? These images contain very long id's generated by the CMS, so reading through a directory is not possible, as the images in cache bare not relation to the file names that are output to the HTML page. It has to all be done from the content that's sent to the page. Or could I even use JQuery to do this??

    Read the article

  • Calculating the null space of a matrix

    - by Ainsworth
    I'm attempting to solve a set of equations of the form Ax = 0. A is known 6x6 matrix and I've written the below code using SVD to get the vector x which works to a certain extent. The answer is approximately correct but not good enough to be useful to me, how can I improve the precision of the calculation? Lowering eps below 1.e-4 causes the function to fail. from numpy.linalg import * from numpy import * A = matrix([[0.624010149127497 ,0.020915658603923 ,0.838082638087629 ,62.0778180312547 ,-0.336 ,0], [0.669649399820597 ,0.344105317421833 ,0.0543868015800246 ,49.0194290212841 ,-0.267 ,0], [0.473153758252885 ,0.366893577716959 ,0.924972565581684 ,186.071352614705 ,-1 ,0], [0.0759305208803158 ,0.356365401030535 ,0.126682113674883 ,175.292109352674 ,0 ,-5.201], [0.91160934274653 ,0.32447818779582 ,0.741382053883291 ,0.11536775372698 ,0 ,-0.034], [0.480860406786873 ,0.903499596111067 ,0.542581424762866 ,32.782593418975 ,0 ,-1]]) def null(A, eps=1e-3): u,s,vh = svd(A,full_matrices=1,compute_uv=1) null_space = compress(s <= eps, vh, axis=0) return null_space.T NS = null(A) print "Null space equals ",NS,"\n" print dot(A,NS)

    Read the article

  • Magento table rates custom options

    - by Usman Ahmad
    in Tablerate.php I want to change the calculation. So for some Products with custom options like width, height the shipping cost must change. I tried with this method to find out if one product in cart has width or height greater than 60cm (example). But currently I have no Idea how to get custom option values... this code working well. foreach ($request->getAllItems() as $item) { echo 'Name: '.$item->getName(). '<br/> SKU:'.$item->getSku(). '<br/> ProductID: '.$item->getProductId(). '<br/> Price: '.$item->getPrice().'<br/>'; } Thanks

    Read the article

  • How to calculate Centered Moving Average of a set of data in Hadoop Map-Reduce?

    - by 100gods
    I want to calculate Centered Moving average of a set of Data . Example Input format : quarter | sales Q1'11 | 9 Q2'11 | 8 Q3'11 | 9 Q4'11 | 12 Q1'12 | 9 Q2'12 | 12 Q3'12 | 9 Q4'12 | 10 Mathematical Representation of data and calculation of Moving average and then centered moving average Period Value MA Centered 1 9 1.5 2 8 2.5 9.5 3 9 9.5 3.5 9.5 4 12 10.0 4.5 10.5 5 9 10.750 5.5 11.0 6 12 6.5 7 9 I am stuck with the implementation of RecordReader which will provide mapper sales value of a year i.e. of four quarter. The RecordReader Problem Question Thread Thanks

    Read the article

< Previous Page | 48 49 50 51 52 53 54 55 56 57 58 59  | Next Page >