Search Results

Search found 470 results on 19 pages for 'scalar udf'.

Page 3/19 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Most efficient way to implement delta time

    - by Starkers
    Here's one way to implement delta time: /// init /// var duration = 5000, currentTime = Date.now(); // and create cube, scene, camera ect ////// function animate() { /// determine delta /// var now = Date.now(), deltat = now - currentTime, currentTime = now, scalar = deltat / duration, angle = (Math.PI * 2) * scalar; ////// /// animate /// cube.rotation.y += angle; ////// /// update /// requestAnimationFrame(render); ////// } Could someone confirm I know how it works? Here what I think is going on: Firstly, we set duration at 5000, which how long the loop will take to complete in an ideal world. With a computer that is slow/busy, let's say the animation loop takes twice as long as it should, so 10000: When this happens, the scalar is set to 2.0: scalar = deltat / duration scalar = 10000 / 5000 scalar = 2.0 We now times all animation by twice as much: angle = (Math.PI * 2) * scalar; angle = (Math.PI * 2) * 2.0; angle = (Math.PI * 4) // which is 2 rotations When we do this, the cube rotation will appear to 'jump', but this is good because the animation remains real-time. With a computer that is going too quickly, let's say the animation loop takes half as long as it should, so 2500: When this happens, the scalar is set to 0.5: scalar = deltat / duration scalar = 2500 / 5000 scalar = 0.5 We now times all animation by a half: angle = (Math.PI * 2) * scalar; angle = (Math.PI * 2) * 0.5; angle = (Math.PI * 1) // which is half a rotation When we do this, the cube won't jump at all, and the animation remains real time, and doesn't speed up. However, would I be right in thinking this doesn't alter how hard the computer is working? I mean it still goes through the loop as fast as it can, and it still has render the whole scene, just with different smaller angles! So this a bad way to implement delta time, right? Now let's pretend the computer is taking exactly as long as it should, so 5000: When this happens, the scalar is set to 1.0: angle = (Math.PI * 2) * scalar; angle = (Math.PI * 2) * 1; angle = (Math.PI * 2) // which is 1 rotation When we do this, everything is timsed by 1, so nothing is changed. We'd get the same result if we weren't using delta time at all! My questions are as follows Mostly importantly, have I got the right end of the stick here? How do we know to set the duration to 5000 ? Or can it be any number? I'm a bit vague about the "computer going too quickly". Is there a way loop less often rather than reduce the animation steps? Seems like a better idea. Using this method, do all of our animations need to be timesed by the scalar? Do we have to hunt down every last one and times it? Is this the best way to implement delta time? I think not, due to the fact the computer can go nuts and all we do is divide each animation step and because we need to hunt down every step and times it by the scalar. Not a very nice DSL, as it were. So what is the best way to implement delta time? Below is one way that I do not really get but may be a better way to implement delta time. Could someone explain please? // Globals INV_MAX_FPS = 1 / 60; frameDelta = 0; clock = new THREE.Clock(); // In the animation loop (the requestAnimationFrame callback)… frameDelta += clock.getDelta(); // API: "Get the seconds passed since the last call to this method." while (frameDelta >= INV_MAX_FPS) { update(INV_MAX_FPS); // calculate physics frameDelta -= INV_MAX_FPS; } How I think this works: Firstly we set INV_MAX_FPS to 0.01666666666 How we will use this number number does not jump out at me. We then intialize a frameDelta which stores how long the last loop took to run. Come the first loop frameDelta is not greater than INV_MAX_FPS so the loop is not run (0 = 0.01666666666). So nothing happens. Now I really don't know what would cause this to happen, but let's pretend that the loop we just went through took 2 seconds to complete: We set frameDelta to 2: frameDelta += clock.getDelta(); frameDelta += 2.00 Now we run an animation thanks to update(0.01666666666). Again what is relevance of 0.01666666666?? And then we take away 0.01666666666 from the frameDelta: frameDelta -= INV_MAX_FPS; frameDelta = frameDelta - INV_MAX_FPS; frameDelta = 2 - 0.01666666666 frameDelta = 1.98333333334 So let's go into the second loop. Let's say it took 2(? Why not 2? Or 12? I am a bit confused): frameDelta += clock.getDelta(); frameDelta = frameDelta + clock.getDelta(); frameDelta = 1.98333333334 + 2 frameDelta = 3.98333333334 This time we enter the while loop because 3.98333333334 = 0.01666666666 We run update We take away 0.01666666666 from frameDelta again: frameDelta -= INV_MAX_FPS; frameDelta = frameDelta - INV_MAX_FPS; frameDelta = 3.98333333334 - 0.01666666666 frameDelta = 3.96666666668 Now let's pretend the loop is super quick and runs in just 0.1 seconds and continues to do this. (Because the computer isn't busy any more). Basically, the update function will be run, and every loop we take away 0.01666666666 from the frameDelta untill the frameDelta is less than 0.01666666666. And then nothing happens until the computer runs slowly again? Could someone shed some light please? Does the update() update the scalar or something like that and we still have to times everything by the scalar like in the first example?

    Read the article

  • Determining actual args an Excel UDF was called with.

    - by Frederick
    I'm adding a user defined function to Excel with varargs-based signature in C++: XLFUNCTIONIMP(MyFunction)(...); When Excel calls MyFunction, it passes it 30 arguments regardless of how many the user entered in the sheet. The extraneous ones are blank strings. MyFunction, however, is designed to accept empty string arguments. As a result, I cannot tell valid empty strings apart from the extraneous ones sent by Excel. A solution could be to obtain the contents of the actual cell where the user entered the function. However, I can't find a way of doing that from within the implementation of my function. Could someone please suggest a way out?

    Read the article

  • How can I make a multi search SPROC/UDF by passing a tabled-value to it?

    - by Shimmy
    I actually want to achieve the following description This is the table argument I want to pass to the server <items> <item category="cats">1</item> <item category="dogs">2</item> </items> SELECT * FROM Item WHERE Item.Category = <one of the items in the XML list> AND Item.ReferenceId = <the corresponding value of that item xml element> --Or in other words: SELECT FROM Items WHERE Item IN XML according to the splecified columns. Am I clear enought? I don't mind to do it in a different way other than xml. What I need is selecting values that mach an array of two of its columns' values.

    Read the article

  • Is it possible to create an efficient UDF alternative to Excel's CUBEVALUE function?

    - by bright
    We'd like to create a simpler alternative to Excel's CUBEVALUE function for retrieving data from an OLAP server. The details aren't critical, but briefly, our function will "know" the source connection and accept a very simple ticker-like parameter and a date, in place of CUBEVALUE's MDX-style parameters. This is for internal use within our firm, just FYI. However, Excel has optimized CUBEVALUE so that calls to the OLAP server are batched. Question: Is there a way to code the new function so that it can similarly batch calls rather than issue a separate query for each cell?

    Read the article

  • How do I define an implicit typecast from my class to a scalar?

    - by Delan Azabani
    I have the following code, which uses a Unicode string class from a library that I'm writing: #include <cstdio> #include "ucpp" main() { ustring a = "test"; ustring b = "ing"; ustring c = "- -"; ustring d; d = "cafe\xcc\x81"; printf("%s\n", (a + b + c[1] + d).encode()); } The encode method of the ustring class instances converts the internal Unicode into a UTF-8 char *. However, because I don't have access to the char class definition, I am unsure on how I can define an implicit typecast (so that I don't have to manually call encode when using with printf, etc).

    Read the article

  • Why SQL functions are faster than UDF

    - by Zerotoinfinite
    Though it's a quite subjective question but I feel it necessary to share on this forum. I have personally experienced that when I create a UDF (even if that is not complex) and use it into my SQL it drastically decrease the performance. But when I use SQL inbuild function they happen to work pretty faster. Conversion , logical & string functions are clear example of that. So, my question is "Why SQL in build functions are faster than UDF"? and it would be an advantage if someone can guide me how can I judge/manipulate function cost either mathematically or logically.

    Read the article

  • Pass table as parameter to SQLCLR TV-UDF

    - by Skeolan
    We have a third-party DLL that can operate on a DataTable of source information and generate some useful values, and we're trying to hook it up through SQLCLR to be callable as a table-valued UDF in SQL Server 2008. Taking the concept here one step further, I would like to program a CLR Table-Valued Function that operates on a table of source data from the DB. I'm pretty sure I understand what needs to happen on the T-SQL side of things; but, what should the method signature look like in the .NET (C#) code? What would be the parameter datatype for "table data from SQL Server?" e.g. /* Setup */ CREATE TYPE InTableType AS TABLE (LocationName VARCHAR(50), Lat FLOAT, Lon FLOAT) GO CREATE TYPE OutTableType AS TABLE (LocationName VARCHAR(50), NeighborName VARCHAR(50), Distance FLOAT) GO CREATE ASSEMBLY myCLRAssembly FROM 'D:\assemblies\myCLR_UDFs.dll' WITH PERMISSION_SET = EXTERNAL_ACCESS GO CREATE FUNCTION GetDistances(@locations InTableType) RETURNS OutTableType AS EXTERNAL NAME myCLRAssembly.GeoDistance.SQLCLRInitMethod GO /* Execution */ DECLARE @myTable InTableType INSERT INTO @myTable(LocationName, Lat, Lon) VALUES('aaa', -50.0, -20.0) INSERT INTO @myTable(LocationName, Lat, Lon) VALUES('bbb', -20.0, -50.0) SELECT * FROM @myTable DECLARE @myResult OutTableType INSERT INTO @myResult MyCLRTVFunction @myTable --returns a table result calculated using the input The lat/lon - distance thing is a silly example that should of course be better handled entirely in SQL; but I hope it illustrates the general intent of table-in - table-out through a table-valued UDF tied to a SQLCLR assembly. I am not certain this is possible; what would the SQLCLRInitMethod method signature look like in the C#? public class GeoDistance { [SqlFunction(FillRowMethodName = "FillRow")] public static IEnumerable SQLCLRInitMethod(<appropriateType> myInputData) { //... } public static void FillRow(...) { //... } } If it's not possible, I know I can use a "context connection=true" SQL connection within the C# code to have the CLR component query for the necessary data given the relevant keys; but that's sensitive to changes in the DB schema. So I hope to just have SQL bundle up all the source data and pass it to the function. Bonus question - assuming this works at all, would it also work with more than one input table?

    Read the article

  • stored procedure vs UDF

    - by TheObserver
    I have a select statement and in a couple of the fields, I want to check if an entry for the record exists in another table and if it does, output 1 value and if it doesn't, provide another value. What would be the best way to do it? When would you use a stored procedure and when would you use a UDF?

    Read the article

  • Table Valued UDF vs Views

    - by vaibhav
    I have never used UDF in sql server. Today I got to know that we can have functions which can return a table. So I just wanted to know can I use functions in place of views. If yes, which one is the better choice and why

    Read the article

  • created persisted computed columns when the user defined scalar function appears to be non-determini

    - by Ralph Shillington
    I have a scalar UDF that I know to be deterministic, however SQL doesn't. Is there a way to declare it as deterministic so that I can then use it in a persisted computed column definition? further clarification: The purpose of this exercise is that I need to harvest out specific values from an XML column on the row. I can't use the value method of the xml column in my computed column definition, but I can use it in a UDF. I know the xpath query in the value method will produce the same output give the same input so while I certainly understand that not all calls to value will be deterministic I want to assert that mine is.

    Read the article

  • Error Handling in T-SQL Scalar Function

    - by hydroparadise
    Ok.. this question could easily take multiple paths, so I will hit the more specific path first. While working with SQL Server 2005, I'm trying to create a scalar funtion that acts as a 'TryCast' from varchar to int. Where I encounter a problem is when I add a TRY block in the function; CREATE FUNCTION u_TryCastInt ( @Value as VARCHAR(MAX) ) RETURNS Int AS BEGIN DECLARE @Output AS Int BEGIN TRY SET @Output = CONVERT(Int, @Value) END TRY BEGIN CATCH SET @Output = 0 END CATCH RETURN @Output END Turns out theres all sorts of things wrong with this statement including "Invalid use of side-effecting or time-dependent operator in 'BEGIN TRY' within a function" and "Invalid use of side-effecting or time-dependent operator in 'END TRY' within a function". I can't seem to find any examples of using try statements within a scalar function, which got me thinking, is error handling in a function is possible? The goal here is to make a robust version of the Convert or Cast functions to allow a SELECT statement carry through depsite conversion errors. For example, take the following; CREATE TABLE tblTest ( f1 VARCHAR(50) ) GO INSERT INTO tblTest(f1) VALUES('1') INSERT INTO tblTest(f1) VALUES('2') INSERT INTO tblTest(f1) VALUES('3') INSERT INTO tblTest(f1) VALUES('f') INSERT INTO tblTest(f1) VALUES('5') INSERT INTO tblTest(f1) VALUES('1.1') SELECT CONVERT(int,f1) AS f1_num FROM tblTest DROP TABLE tblTest It never reaches point of dropping the table because the execution gets hung on trying to convert 'f' to an integer. I want to be able to do something like this; SELECT u_TryCastInt(f1) AS f1_num FROM tblTest fi_num __________ 1 2 3 0 5 0 Any thoughts on this? Is there anything that exists that handles this? Also, I would like to try and expand the conversation to support SQL Server 2000 since Try blocks are not an option in that scenario. Thanks in advance.

    Read the article

  • Pass scalar/list context to called subroutine

    - by Will
    I'm trying to write a sub that takes a coderef parameter. My sub does some initialization, calls the coderef, then does some cleanup. I need to call the coderef using the same context (scalar, list, void context) that my sub was called in. The only way I can think of is something like this: sub perform { my ($self, $code) = @_; # do some initialization... my @ret; my $ret; if (not defined wantarray) { $code->(); } elsif (wantarray) { @ret = $code->(); } else { $ret = $code->(); } # do some cleanup... if (not defined wantarray) { return; } elsif (wantarray) { return @ret; } else { return $ret; } } Obviously there's a good deal of redundancy in this code. Is there any way to reduce or eliminate any of this redundancy? EDIT   I later realized that I need to run $code->() in an eval block so that the cleanup runs even if the code dies. Adding eval support, and combining the suggestions of user502515 and cjm, here's what I've come up with. sub perform { my ($self, $code) = @_; # do some initialization... my $w = wantarray; return sub { my $error = $@; # do some cleanup... die $error if $error; # propagate exception return $w ? @_ : $_[0]; }->(eval { $w ? $code->() : scalar($code->()) }); } This gets rid of the redundancy, though unfortunately now the control flow is a little harder to follow.

    Read the article

  • Computing the scalar product of two vectors in C++

    - by HowardRoark
    I am trying to write a program with a function double_product(vector<double> a, vector<double> b) that computes the scalar product of two vectors. The scalar product is $a_{0}b_{0}+a_{1}b_{1}+...+a_{n-1}b_{n-1}$. Here is what I have. It is a mess, but I am trying! #include <iostream> #include <vector> using namespace std; class Scalar_product { public: Scalar_product(vector<double> a, vector<double> b); }; double scalar_product(vector<double> a, vector<double> b) { double product = 0; for (int i = 0; i <= a.size()-1; i++) for (int i = 0; i <= b.size()-1; i++) product = product + (a[i])*(b[i]); return product; } int main() { cout << product << endl; return 0; }

    Read the article

  • How do I correctly multiply an XMMATRIX by a scalar?

    - by user43129
    Using DirectXMath and its XMMATRIX structure in C++ and Direct X 11, how does one multiply that matrix structure by a single float scalar? I want to implement the operation B = A * f; where A and B are XMMATRIX and f is a float. I found all sorts of functions to multiply a matrix by another matrix or a vector. I found all sorts of functions to construct matrices. I could find no scalar multiplication! Why is there no such function? Is there no use case? Did I miss something? How do I implement scalar multiplication?

    Read the article

  • SQLRally and SQLRally - Session material

    - by Hugo Kornelis
    I had a great week last week. First at SQLRally Nordic , in Stockholm, where I presented a session on how improvements to the OVER clause can help you simplify queries in SQL Server 2012 enormously. And then I continued straight on into SQLRally Amsterdam , where I delivered a session on the performance implications of using user-defined functions in T-SQL. I understand that both events will make my slides and demo code downloadable from their website, but this may take a while. So those who do not...(read more)

    Read the article

  • SQLRally Nordic 2012 – session material

    - by Hugo Kornelis
    As some of you might know, I have been to SQLRally Nordic 2012 in Copenhagen earlier this week. I was able to attend many interesting sessions, I had a great time catching up with old friends and meeting new people, and I was allowed to present a session myself. I understand that the PowerPoint slides and demo code I used in my session will be made available through the SQLRally website – but I don’t know how long it will take the probably very busy volunteers to do so. And I promised my attendees...(read more)

    Read the article

  • How to execute scalar function using Enterprise Library?

    - by Vadim
    I'm having trouble to execute scalar function using Enterprise Library 5.0. The code looks something like that: somedDb.ExecuteScalar(CommandType.Text, "SELECT dbo.MyFunction('param')"); When the code is executed, I get the following error: Cannot find either column "dbo" or the user-defined function or aggregate "dbo.MyFunction", or the name is ambiguous.

    Read the article

  • Can't modify constant item in scalar assignment

    - by joe
    sub new { my $class = shift; my $ldap_obj = Net::LDAP->new( 'test.company.com' ) or die "$@"; my $self = { _ldap = $ldap_obj, _dn ='dc=users,dc=ldap,dc=company,dc=com', _dn_login = 'dc=login,dc=ldap,dc=company,dc=com', _description ='company', }; # Print all the values just for clarification. bless $self, $class; return $self; } what is wrong on this code : i got this error Can't modify constant item in scalar assignment at Core.pm line 12, near "$ldap_obj,"

    Read the article

  • passing a scalar query result to coalesce

    - by Fakrudeen
    How can I pass the result from a scalar [single row, single value] query to coalesce? I am trying to pick the priority as (the biggest priority so far in the table) + 1. [0 if it is the first row.] create trigger priority_SuperRuleSamples before insert on SuperRuleSamples FOR EACH ROW SET NEW.Priority=coalesce(NEW.Priority, coalesce( select Priority from SuperRuleSamples order by Priority desc limit 1, -1 )+1 )

    Read the article

  • Format CD-rom on Windows 7 that Windows 95 can read

    - by Joe Majsterski
    I pulled out my ancient Pentium 100Mhz running Windows 95 to play a game from 1996. This game has a critical bug in it that requires a patch. The problem is, the computer has no way to connect to the Internet or to the LAN. I tried burning a CD-rom on my Windows 7 PC to run on the Win95 PC, but it doesn't even recognize that there's a disc in the drive. I did some research, and apparently Windows 95 can't read UDF format. All the solutions recommend, of course, downloading a driver or fix or somesuch, which is my entire problem in the first place. I tried formatting the CD-rom on my Win7 PC, but all the format choices are versions of UDF. Is there a way to get Windows 7 to format in way that is compatible with Windows 95? EDIT: I think the problem may be that I only have CD-RWs. I think a regular CD-R might work, but I can't find any in the house. I'll see if I can scrounge one up and try that.

    Read the article

  • Entity Framework 4 mapping fragment error when adding new entity scalar

    - by Jason Morse
    I have an Entity Framework 4 model-first design. I create a first draft of my model in the designer and all was well. I compiled, generated database, etc. Later on I tried to add a string scalar (Nullable = true) to one of my existing entities and I keep getting this type of error when I compile: Error 3004: Problem in mapping fragments starting at line 569: No mapping specified for properties MyEntity.MyValue in Set MyEntities. An Entity with Key (PK) will not round-trip when: Entity is type [MyEntities.MyEntity] I keep having to manually open the EDMX file and correct the XML whenever I add scalars. Ideas on what's going on?

    Read the article

  • ASP Classic Named Parameter in Paramaterized Query: Must declare the scalar variable

    - by My Alter Ego
    I'm trying to write a parameterized query in ASP Classic, and it's starting to feel like i'm beating my head against a wall. I'm getting the following error: Must declare the scalar variable "@something". I would swear that is what the hello line does, but maybe i'm missing something... <% OPTION EXPLICIT %> <!-- #include file="../common/adovbs.inc" --> <% Response.Buffer=false dim conn,connectionString,cmd,sql,rs,parm connectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Data Source=.\sqlexpress;Initial Catalog=stuff" set conn = server.CreateObject("adodb.connection") conn.Open(connectionString) set cmd = server.CreateObject("adodb.command") set cmd.ActiveConnection = conn cmd.CommandType = adCmdText cmd.CommandText = "select @something" cmd.NamedParameters = true cmd.Prepared = true set parm = cmd.CreateParameter("@something",advarchar,adParamInput,255,"Hello") call cmd.Parameters.append(parm) set rs = cmd.Execute if not rs.eof then Response.Write rs(0) end if %>

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >