Search Results

Search found 24043 results on 962 pages for 'private methods'.

Page 70/962 | < Previous Page | 66 67 68 69 70 71 72 73 74 75 76 77  | Next Page >

  • Matlab code help. Backward Euler method.

    - by m0s
    Here is the matlab/freemat code I got to solve ODE numerically using backward Euler method. However the results are inconsistent with my textbook results, and sometimes even ridiculously inconsistent. Please point out what is wrong with the code. I have already asked this question on mathoverflow.com no help there, hope someone here can help. function [x,y]=backEuler(f,xinit,yinit,xfinal,h) %f - this is your y prime %xinit - initial X %yinit - initial Y %xfinal - final X %h - step size n=(xfinal-xinit)/h; %Calculate steps %Inititialize arrays... %1st elements take xinit and yinit corespondigly, the rest fill with 0s x=[xinit zeros(1,n)]; y=[yinit zeros(1,n)]; %Numeric routine for i=1:n x(i+1)=x(i)+h; ynew=y(i)+h*(f(x(i),y(i))); y(i+1)=y(i)+h*f(x(i+1),ynew); end end

    Read the article

  • Getting the name of a child class in the parent class (static context)

    - by Benoit Myard
    Hi everybody, I'm building an ORM library with reuse and simplicity in mind; everything goes fine except that I got stuck by a stupid inheritance limitation. Please consider the code below: class BaseModel { /* * Return an instance of a Model from the database. */ static public function get (/* varargs */) { // 1. Notice we want an instance of User $class = get_class(parent); // value: bool(false) $class = get_class(self); // value: bool(false) $class = get_class(); // value: string(9) "BaseModel" $class = __CLASS__; // value: string(9) "BaseModel" // 2. Query the database with id $row = get_row_from_db_as_array(func_get_args()); // 3. Return the filled instance $obj = new $class(); $obj->data = $row; return $obj; } } class User extends BaseModel { protected $table = 'users'; protected $fields = array('id', 'name'); protected $primary_keys = array('id'); } class Section extends BaseModel { // [...] } $my_user = User::get(3); $my_user->name = 'Jean'; $other_user = User::get(24); $other_user->name = 'Paul'; $my_user->save(); $other_user->save(); $my_section = Section::get('apropos'); $my_section->delete(); Obviously, this is not the behavior I was expecting (although the actual behavior also makes sense).. So my question is if you guys know of a mean to get, in the parent class, the name of child class.

    Read the article

  • Visual Studio Formatting -- Change Method Color

    - by Daniel
    The default appearance of a method for example, ".ToString()" is by default the color black. I want to make it a different color to stand out but I do not see any options that reference this option specifically. I remember one of former collegues showing me his VS IDE years ago and he had it setup this way but I cannot recall what he did. Does anyone have any ideas on how to do this?

    Read the article

  • matlab fit exp2

    - by HelloWorld
    I'm unsuccessfully looking for documentation of fit function using exp2 (sum of 2 exponents). How to operate the function is clear: [curve, gof] = fit(x, y,'exp2'); But since there are multiple ways to fit a sum of exponents I'm trying to find out what algorithm is used. Particularly what happens when I'm fitting one exponent (the raw data) with a bit of noise, how the exponents are spread. I've simulated several cases, and it seems that it "drops" all the weight on the second set of coefficients, but row data analysis often shows different behavior. Does anyone have suggestions of documentation?

    Read the article

  • C# extension method doesn't seem to exist

    - by blahblah
    I can't seem to get the following extension method to be found in another class in the same namespace (MyProject.Util). using System.Collections.Specialized; namespace MyProject.Util { public static class Extensions { public static string Get( this NameValueCollection me, string key, string def ) { return me[key] ?? def; } } } As you can see it's basically another version of foo[bar] ?? baz, but I still don't understand why VS2008 fails to compile telling me that no version of Get takes two arguments. Any ideas?

    Read the article

  • Kohana Database Library - How to Execute a Query with the Same Parameters More Than Once?

    - by Noah Goodrich
    With the following bit of code: $builder = ORM::factory('branch')->where('institution_id', $this->institution->id)->orderby('name'); I need to first execute: $count = $builder->count_all(); Then I need to execute: $rs = $builder->find_all($limit, $offset); However, it appears that when I execute the first query the stored query parameters are cleared so that a fresh query can be executed. Is there a way to avoid having the parameters cleared or at least copy them easily without having to reach directly into the Database driver object that stores the query parameters and copy them out? We are using Kohana 2.3.4 and upgrading is not an option.

    Read the article

  • What's an easy way to set up object communication in Obj-C?

    - by seaworthy
    I am trying to send a slider value from a controller object to a method of a model object. The later is implemented in the separate file and I have appropriate headers. I think the problem is that I am not sure how to instantiate the receiver in order to produce a working method for the controller. Here is the controller's method. -(IBAction)setValue:(id)slider {[Model setValue:[slider floatValue]];} @implementation Model -(void)setValue:(float)n{ printf("%f",n); } @end What I get is 'Model' may not respond to '+setValue' warning and no output in my console. Any insight is appreciated.

    Read the article

  • iPhone: should initWithNibName:bundle: method be deleted from UIViewController class if not used?

    - by Scott Pendleton
    I notice that this method is provided in UIViewController .m files, but is commented out: - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil I had been leaving that method commented out, or even deleting it. But then I looked at this line inside the method: if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) I assume that if it were truly important for self to be set equal to super, then Apple would not have the method be commented out by default. On the other hand, if I do need to do some customization in that method, why do I need to set self = super? What's the best practice, and why?

    Read the article

  • SVD factorization

    - by Simon
    How can i use the bidiagonal and diagonal form to compute the SVD factorization. I think my real problem is that i don't understand this concepts.

    Read the article

  • Predicate<INT> match question

    - by Petr
    Hi, I do not understand how following code works. Specifically, I do not understand using of "return i<3". I would expect return i IF its < than 3. I always though that return just returns value. I could not even find what syntax is it. Second question, it seems to me like using anonymous method (delegate(int i)) but could be possible to write it with normal delegate pointing to method elsewere? Thanks List<int> listOfInts = new List<int> { 1, 2, 3, 4, 5 }; List<int> result = listOfInts.FindAll(delegate(int i) { return i < 3; });

    Read the article

  • ControlCollection extension method optimazation

    - by Johan Leino
    Hi, got question regarding an extension method that I have written that looks like this: public static IEnumerable<T> FindControlsOfType<T>(this ControlCollection instance) where T : class { T control; foreach (Control ctrl in instance) { if ((control = ctrl as T) != null) { yield return control; } foreach (T child in FindControlsOfType<T>(ctrl.Controls)) { yield return child; } } } public static IEnumerable<T> FindControlsOfType<T>(this ControlCollection instance, Func<T, bool> match) where T : class { return FindControlsOfType<T>(instance).Where(match); } The idea here is to find all controls that match a specifc criteria (hence the Func<..) in the controls collection. My question is: Does the second method (that has the Func) first call the first method to find all the controls of type T and then performs the where condition or does the "runtime" optimize the call to perform the where condition on the "whole" enumeration (if you get what I mean). secondly, are there any other optimizations that I can do to the code to perform better. An example can look like this: var checkbox = this.Controls.FindControlsOfType<MyCustomCheckBox>( ctrl => ctrl.CustomProperty == "Test" ) .FirstOrDefault();

    Read the article

  • Why is my Extension Method not showing up in my test class?

    - by Robert Harvey
    I created an extension method called HasContentPermission on the System.Security.Principal.IIdentity interface: namespace System.Security.Principal { public static bool HasContentPermission (this IIdentity itentity, int contentID) { // I do stuff here return result; } } And I call it like this: bool hasPermission = User.Identity.HasPermission(contentID); Works like a charm. Now I want to unit test it. To do that, all I really need to do is call the extension method directly, so: using System.Security.Principal; namespace MyUnitTests { [TestMethod] public void HasContentPermission_PermissionRecordExists_ReturnsTrue() { IIdentity identity; bool result = identity.HasContentPermission(... But HasContentPermission won't intellisense. I tried creating a stub class that inherits from IIdentity, but that didn't work either. Why? Or am I going about this the wrong way?

    Read the article

  • php 5.1.6 magic __toString method

    - by NachoF
    In codeigniter Im trying to use this plugin which requires I implement a toString method in my models. My toString method simply does return $this->name On my local machine with php 5.3 everything works just fine but on the production server with php 5.1.6 it shows "Object id#48" where the value of the name property of that object should appear..... I found something about the problem here but I still dont understand... How can I fix this?

    Read the article

  • An analog of String.Join(string, string[]) for IEnumerable<T>

    - by abatishchev
    class String contains very useful method - String.Join(string, string[]). It creates a string from an array, separating each element of array with a symbol given. But general - it doesn't add a separator after the last element! I uses it for ASP.NET coding for separating with "<br />" or Environment.NewLine. So I want to add an empty row after each row in asp:Table. What method of IEnumerable<TableRow> can I use for the same functionality?

    Read the article

  • Objective-C method not being called

    - by Matt S.
    It's either because of the fact I'm tired or because I'm doing it wrong, but for some reason I can't get it to call a method. Here's what I'm trying to call: -(void)newHighScore:(int)d Which right now just does an NSLog saying "yea I'm working!" I'm calling it like this: [highscore newHighScore:score]; highscore is what I called the HighScore class in the .h, and score is an int with the score.

    Read the article

  • Why MyModel.all works in Rails ?

    - by AntonAL
    Hi, i don't understand this little thing: Suppose, we have "Person" model class Person < ActiveRecord::Base end Why Person.all works ? Person.all.each { |p| do_something } This syntax tells us, that we have Person class-object instanciated somewhere ? Or is it some convention over configuration case ?

    Read the article

  • Deserialize Stream to List<T> or any other type

    - by Sam
    Attempting to deserialize a stream to List<T> (or any other type) and am failing with the error: The type arguments for method 'Foo.Deserialize<T>(System.IO.Stream)' cannot be inferred from the usage. Try specifying the type arguments explicitly. This fails: public static T Deserialize<T>(this Stream stream) { BinaryFormatter bin = new BinaryFormatter(); return (T)bin.Deserialize(stream); } But this works: public static List<MyClass.MyStruct> Deserialize(this Stream stream) { BinaryFormatter bin = new BinaryFormatter(); return (List<MyClass.MyStruct>)bin.Deserialize(stream); } or: public static object Deserialize(this Stream stream) { BinaryFormatter bin = new BinaryFormatter(); return bin.Deserialize(stream); } Is it possible to do this without casting, e.g. (List<MyStruct>)stream.Deserialize()?

    Read the article

  • Why can't I pass self as a named argument to an instance method in Python?

    - by Joseph Garvin
    This works: >>> def bar(x, y): ... print x, y ... >>> bar(y=3, x=1) 1 3 And this works: >>> class foo(object): ... def bar(self, x, y): ... print x, y ... >>> z = foo() >>> z.bar(y=3, x=1) 1 3 And even this works: >>> foo.bar(z, y=3, x=1) 1 3 But why doesn't this work? >>> foo.bar(self=z, y=3, x=1) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unbound method bar() must be called with foo instance as first argument (got nothing instead) This makes metaprogramming more difficult, because it requires special case handling. I'm curious if it's somehow necessary by Python's semantics or just an artifact of implementation.

    Read the article

  • How do i generate a random integer between min and max in java?

    - by David
    What method returns a random int between a min and max? Or does no such method exist? what i'm looking for is something like this: NAMEOFMETHOD (min, max) (where min and max are ints) that returns soemthing like this: 8 (randomly) if such a method does exist could you please link to the relevant documentation with your answer. thanks.

    Read the article

  • Possible to write an Extension Method for ASP.NET's Html.ActionLink() method?

    - by Pretzel
    Right now, I'm trying to work around an IE6/7 bug which requires the wrapping of the </a closing tag with this IE specific comment to make some drop-down menu work: <!--[if IE 7]><!--></a><!--<![endif]--> Unfortunately, I cannot inject this directly into my View page code like this: <%= Html.ActionLink("LinkName<!--[if IE 7]><!--></a><!--<![endif]-->","Action","Controller") %> As Html.ActionLink will do the safe thing and filter out the comment to prevent a Javascript injection attack. Ok, cool. I'm fine with that. Good design decision. What I'd like to do is write an Extension Method to this, but the process is eluding me as I haven't done this before. I thought this would work, but Intellisense doesn't seem to be picking up this Extension method that I've written. public static class MyLinkExtensions { public static string ActionLinkIE(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName) { return LinkExtensions.ActionLink(htmlHelper, linkText, actionName, controllerName). Replace(@"</a>", @"<!--[if IE 7]><!--></a><!--<![endif]-->"); } } Any suggestions?

    Read the article

  • Static method not called

    - by Smile
    I'm trying to call a static method (printABC()) in this class but it's not working. If I uncomment both of the lines marked T_T (1 and 2), it works! Why does it fail with only one of the lines? import java.util.Scanner; class pro0009 { static Scanner in = new Scanner(System.in); static int A,B,C; static void printABC(){ String ABC = in.nextLine(); ABC=ABC.replace("A"," "+A+" "); ABC=ABC.replace("B"," "+B+" "); ABC=ABC.replace("C"," "+C+" "); //System.out.print(ABC.substring(1)); System.out.print(ABC); } public static void main(String[] args){ int x = in.nextInt(); //1 int y = in.nextInt(); //2 int z = in.nextInt(); //3 if(x<y){//1<2 if(x<z){ //1<3 if(y<z){//x<y<z 2<3 //1<2<3 A=x; B=y; C=z; printABC();//T_T 1 System.out.println("Here"); //pro0009.printABC();//T_T 2 //System.out.println("Here2"); }else{ //x<z<y A=x; B=z; C=y; } }else{//z<x<y A=z; B=x; C=y; } }else{//y<x if(y<z){ if(x<z){//y<x<z A=y; B=x; C=z; }else{//y<z<x A=y; B=z; C=x; } }else{//z<y<x A=z; B=y; C=x; } } } }

    Read the article

  • Java method help

    - by dalton conley
    Ok, so I'm working on a project for a class I'm taking.. simple music library. Now I'm having some issues, the main issue is I'm getting "non-static method cannot be referenced from a static context" Here is a function I have public void addSong() { Scanner scan = new Scanner(System.in); Song temp = new Song(); int index = countFileLines(Main.databaseFile); index = index + 2; temp.index = index; System.out.print("Enter the artist name: "); temp.artist.append(scan.next()); } Now thats in a class file called LibraryFunctions. So I can access it with LibraryFunctions.addSong(); Now I'm trying to run this in my main java file and its giving me the error, I know why the error is happening, but what do I do about it? If I make addSong() a static function then it throws errors at me with the Song temp = new Song() being static. Kind of ironic. Much help is appreciated on this!

    Read the article

  • An analog of String.Join(string, string[]) for List<T> or other generic enumerable

    - by abatishchev
    class String contains very useful method - String.Join(string, string[]). It creates a string from an array, separating each element of array with a symbol given. But general - it doesn't add a separator after the last element! I uses it for ASP.NET coding for separating with "<br />" or Environment.NewLine. So I want to add an empty row after each row in asp:Table. What method of IEnumerable<TableRow> can I use for the same functionality?

    Read the article

  • Problem using a method in Ruby

    - by Rafal
    I'm very new to Ruby (and OOP as well) and I don't know why the following thing doesn't work in Ruby I extended the String class with a new method. Easy enough. Now I want to extend the Fixnum class. A String object appears somewhere in the class, but I can't use the method that I defined earlier. Why? Is this normal?

    Read the article

  • incremental way of counting quantiles for large set of data

    - by Gacek
    I need to count the quantiles for a large set of data. Let's assume we can get the data only through some portions (i.e. one row of a large matrix). To count the Q3 quantile one need to get all the portions of the data and store it somewhere, then sort it and count the quantile: List<double> allData = new List<double>(); foreach(var row in matrix) // this is only example. In fact the portions of data are not rows of some matrix { allData.AddRange(row); } allData.Sort(); double p = 0.75*allData.Count; int idQ3 = (int)Math.Ceiling(p) - 1; double Q3 = allData[idQ3]; Now, I would like to find a way of counting this without storing the data in some separate variable. The best solution would be to count some parameters od mid-results for first row and then adjust it step by step for next rows. Note: These datasets are really big (ca 5000 elements in each row) The Q3 can be estimated, it doesn't have to be an exact value. I call the portions of data "rows", but they can have different leghts! Usually it varies not so much (+/- few hundred samples) but it varies! This question is similar to this one: http://stackoverflow.com/questions/1058813/on-line-iterator-algorithms-for-estimating-statistical-median-mode-skewness But I need to count quantiles. ALso there are few articles in this topic, i.e.: http://web.cs.wpi.edu/~hofri/medsel.pdf http://portal.acm.org/citation.cfm?id=347195&dl But before I would try to implement these, I wanted to ask you if there are maybe any other, qucker ways of counting the 0.25/0.75 quantiles?

    Read the article

< Previous Page | 66 67 68 69 70 71 72 73 74 75 76 77  | Next Page >