Search Results

Search found 2562 results on 103 pages for 'vector'.

Page 84/103 | < Previous Page | 80 81 82 83 84 85 86 87 88 89 90 91  | Next Page >

  • 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

  • Why am I not getting correct result when I calculate exponent with ^ in C++?

    - by xbonez
    I am using Bode's formuala to calculate distance of nth planet from sun dist = (4 + 3*(2^(n-2)))/10 If I calculate the distance this way, I get the right values: dist[2] = ((4 + 3*1)/10.0) ; dist[3] = ((4 + 3*2)/10.0) ; dist[4] = ((4 + 3*4)/10.0) ; But doing it this way, gives me incorrect values: vector <double> dist(5); for (unsigned int i = 2; i < 5; i++) { dist[i] = ((4 + 3*(2^(3-2)))/10.0) ; } Why so?

    Read the article

  • struct with template variables in c++

    - by monkeyking
    I'm playing around with template, so I'm not trying to reinvent the std::vector, I'm trying to get a grasp of templateting in c++. Can I do the following template <typename T> typedef struct{ size_t x; T *ary; }array; What I'm trying to do is a basic templated version of typedef struct{ size_t x; int *ary; }iArray; It looks like its working if I use a class instead of struct, so is it not possible with typedef structs? thanks

    Read the article

  • Determining if two rays intersect

    - by Faken
    I have two rays on a 2D plane that extend to infinity but both have a starting point. They are both described by a starting point and a vector in the direction of the ray extending to infinity. I want to find out if the two rays intersect but i don't need to know where they intersect (its part of a collision detection algorithm). Everything i have looked at so far describes finding the intersection point of two lines or line segments. Anyone know a fast algorithm to solve this?

    Read the article

  • Collection type generated by for with yield

    - by Jesper
    When I evaluate a for in Scala, I get an immutable IndexedSeq (a collection with array-like performance characteristics, such as efficient random access): scala> val s = for (i <- 0 to 9) yield math.random + i s: scala.collection.immutable.IndexedSeq[Double] = Vector(0.6127056766832756, 1.7137598183155291, ... Does a for with a yield always return an IndexedSeq, or can it also return some other type of collection class (a LinearSeq, for example)? If it can also return something else, then what determines the return type, and how can I influence it? I'm using Scala 2.8.0.RC3.

    Read the article

  • measuring uncertainty in matlabs svmclassify

    - by Mark
    I'm doing contextual object recognition and I need a prior for my observations. e.g. this space was labeled "dog", what's the probability that it was labeled correctly? Do you know if matlabs svmclassify has an argument to return this level of certainty with it's classification? If not, matlabs svm has the following structures in it: SVM = SupportVectors: [11x124 single] Alpha: [11x1 double] Bias: 0.0915 KernelFunction: @linear_kernel KernelFunctionArgs: {} GroupNames: {11x1 cell} SupportVectorIndices: [11x1 double] ScaleData: [1x1 struct] FigureHandles: [] Can you think of any ways to compute a good measure of uncertainty from these? (Which support vector to use?) Papers/articles explaining uncertainty in SVMs welcome. More in depth explanations of matlabs SVM are also welcome. If you can't do it this way, can you think of any other libraries with SVMs that have this measure of uncertainty?

    Read the article

  • What is a good standard for code width?

    - by BillyONeal
    Hello everyone :) I've heard in several places that it's bad to have code that is too wide onscreen. For example: for (std::vector<EnumServiceInformation>::const_iterator currentService = services.begin(); currentService != services.end(); currentService++) However, I've heard many arguments for 80 character wide limits. I'm assuming this 80 character limit comes from the traditional command prompt, which is typically 80 characters wide. However -- most of us are working on something much better than a typical command prompt, and I feel that using an 80 character limit encourages use of variable names that are far too short and do not describe what the variable is used for. What is a reasonable limit for a new project with no existing coding width standard?

    Read the article

  • [MATH]Project an axis to a plane

    - by Robert
    how do i project the X axis to a plane if the plane is defined by three points? see pic here: http://129.25.16.135:2080/v6.5/books/usb/graphics/iconventions-local-surfaces.png The default local 1-direction is the projection of the global x-axis onto the surface. If the global x-axis is within 0.1° of being normal to the surface, the local 1-direction is the projection of the global z-axis onto the surface. let's suppose that these points are: t1 = [-0.362879991531372, 0.357021987438202, -0.373737007379532] t2 = [-0.383525013923645, 0.371621012687683, -0.383549988269806] t3 = [-0.383534014225006, 0.34629300236702, -0.38544899225235] is the vector [0.78280971952246, -0.0307519963686645, 0.411184845614438] correct answer in this case? i've calculated the angle between the surf and x (1,0,0) is ~28°. and can you give the entire procedure for the calculation, because i'm just puzzled.

    Read the article

  • C++ Array of Variable sized Arrays

    - by adam
    I am very new to C++ and I realise the following is not necessarily as easy as I'd like it to be, but I'd really appreciate a more expert opinion. I am essentially trying to achieve a dynamic iteration over a variable sized array of variable sized arrays similar to the following. String *2d_array[][] = {{"A1","A2"},{"B1","B2","B3"},{"C1"}}; for (int i=0; i<2d_array.length; i++) { for (int j=0; j<2d_array[i].length; j++) { print(2d_array[i][j]); } } Is there a reasonable way to do this? Perhaps by using a vector, or another struct? Thanks :)

    Read the article

  • Unexpected result from reduce function

    - by StackedCrooked
    I would like to get the smallest element from a vector. For this I use combine the reduce and min functions. However, when providing my own implementation of min I get unexpected results: user=> (reduce (fn [x y] (< x y) x y) [1 2 3 2 1 0 1 2]) 2 user=> (reduce min [1 2 3 2 1 0 1 2 3]) 0 The reduce with standard min returns 0 as expected. However, when I provide my own implementation it returns 2. What am I doing wrong?

    Read the article

  • Some exam questions about C++ vectors and arrays...

    - by xbonez
    Hey guys, I have a CS exam tomorrow. Just want to get a few questions cleared up. Thanks a lot, and I really appreciate the help. Que 1. What are parallel vectors? Vectors of the same length that contain data that is meant to be processed together Vectors that are all of the same data type Vectors that are of the same length Any vector of data type parallel Que 2. Arrays are faster and more efficient than vectors. True False Que 3. Arrays can be a return type of a function call. True False Que 4. Vectors can be a return type of a function call. True False

    Read the article

  • allocator with no template

    - by Merni
    Every stl container take an allocator as a second object, template < class T, class Allocator = allocator<T> > class vector; If you write your own class It is possible to use your own allocator. But is it possible to write your own allocator without using templates? For example, writing this function is not easy if you are not allowed to use templates pointer allocate(size_type n, const_pointer = 0) { void* p = std::malloc(n * sizeof(T)); if (!p) throw std::bad_alloc(); return static_cast<pointer>(p); } Because how could you know the size of T?

    Read the article

  • Designing entire webpages as SVG files

    - by user1311390
    Disclaimer I realize that given the absurdity of the title, this sounds like a troll. However, it's a genuine question. My background involves OpenGL / x86 assembly. I've recently started learning web programming. I really like SVG + CSS, and was wondering -- why do people not design entire webpages in SVG? Context SVG provides beautiful primitive: quadratic + cubic bezier curves; lines + filling -- all as vector graphics SVG provides text SVG provides affine transformations Questions Are there examples of people designing entire websites as a giant SVG file? If not, what the limitations? Are there performance hits when using SVG primitives as opposed to divs/tables?

    Read the article

  • HELP!! Implementing a search to match the specified author and displaying a book by the specified publisher

    - by Brian
    Hey guys! So i'm having problems with my assignment. I successfully got it to run multiple last names by the author, but now, I need to find all books by author, which means searching the collection for all books that match the specified author and I also need to find all books by publisher, which displays a list of books by the specified publisher. How would I implement this? Would I use string or vector? Any help will be much appreciated!

    Read the article

  • Why can I derived from a templated/generic class based on that type in C# / C++

    - by stusmith
    Title probably doesn't make a lot of sense, so I'll start with some code: class Foo : public std::vector<Foo> { }; ... Foo f; f.push_back( Foo() ); Why is this allowed by the compiler? My brain is melting at this stage, so can anyone explain whether there are any reasons you would want to do this? Unfortunately I've just seen a similar pattern in some production C# code and wondered why anyone would use this pattern.

    Read the article

  • Filtering spectrum using FIR filters

    - by Alex Hoppus
    If i have signal values x[T] and filter coefficients b[i], i can perform filtering using convolution. Suppose i have spectrum of x (after FFT) and i need to perform filtering using filters coefficients, how can i perform this? I heard that in frequency domain it will be multiplying, rather than convolution (time domain). But i can't find an equation to use it. I have 614000 values in y = fft(x[T]) vector and 119 filter coefficients (generated using fdatool), i can't multiply them directly ... Thanks.

    Read the article

  • Javascript function returning number with two decimals...?

    - by muzzledBYbrass
    I have a function to return points along a line and my return comes back with two decimal points...? For example, a return of my variable px will be something like -88.4029.032940598. vx is the x vector and mult is the distance of the line plus distance to calculate the point. Here is the operation that is returning these values: var mult = parseFloat(mag + theUnit); var px = coord_one.x_point + (vx * mult); console.log(px); Never have seen this before- I appreciate any and all help!

    Read the article

  • C++ typedef for partial templates

    - by Gokul
    Hi, i need to do a typedef like this. template< class A, class B, class C > class X { }; template< class B, class C > typedef X< std::vector<B>, B, C > Y; I just found that it is not supported in C++. Can someone advise me on how to achieve the same through alternative means? Thanks, Gokul.

    Read the article

  • IN r, how to combine the summary together

    - by alex
    say i have 5 summary for 5 sets of data. how can i get those number out or combine the summary in to 1 rather than 5 V1 V2 V3 V4 Min. : 670.2 Min. : 682.3 Min. : 690.7 Min. : 637.6 1st Qu.: 739.9 1st Qu.: 737.2 1st Qu.: 707.7 1st Qu.: 690.7 Median : 838.6 Median : 798.6 Median : 748.3 Median : 748.3 Mean : 886.7 Mean : 871.0 Mean : 869.6 Mean : 865.4 3rd Qu.:1076.8 3rd Qu.:1027.6 3rd Qu.:1070.0 3rd Qu.: 960.8 Max. :1107.8 Max. :1109.3 Max. :1131.3 Max. :1289.6 V5 Min. : 637.6 1st Qu.: 690.7 Median : 748.3 Mean : 924.3 3rd Qu.: 960.8 Max. :1584.3 how can i have 1 table looks like v1 v2 v3 v4 v5 Min. : 1st Qu.: Median : Mean : 3rd Qu.: Max. : or how to save those number as vector so i can use matrix to generate a table

    Read the article

  • [C++] Why am I not getting the same values?

    - by xbonez
    I am using Bode's formuala to calculate distance of nth planet from sun dist = (4 + 3*(2^(n-2)))/10 If I calculate the distance this way, I get the right values: dist[2] = ((4 + 3*1)/10.0) ; dist[3] = ((4 + 3*2)/10.0) ; dist[4] = ((4 + 3*4)/10.0) ; But doing it this way, gives me incorrect values: vector double> dist(5); for (unsigned int i = 2; i < 5; i++) { dist[i] = ((4 + 3*(2^(3-2)))/10.0) ; } ` Why so?

    Read the article

  • Qt "no matching function for call"

    - by Blin
    I have no matching function for call to 'saveLine::saveLine()' error when compiling my application. The construcor is never actually called. saveLine class definition: class saveLine { public: saveLine(QWidget *parent); private: QPushButton *selectButton, *acceptButton; QLabel *filePath; QLineEdit *allias; }; saveLine is used in another class which is defined as follows: class MWindow : public QWidget { Q_OBJECT public: MWindow(QWidget *parent=0); private: saveLine line1; }; error points to MWindow constructor implementation MWindow::MWindow(QWidget *parent):QWidget(parent) { this->setWindowTitle("Launcher"); this->resize(600,600); } What should i do? I intend to use saveLine class in a vector, to create lines at runtime.

    Read the article

  • Can I use MFC objects in STL containers?

    - by Jesse Stimpson
    The following code doesn't compile for me in MSVC2005: std::vector<CMenu> vec(10); CMenu is an MFC menu object (such as a context menu). Through some testing I learned that CMenu does not have a public copy constructor. To do what I wanted to do, I needed to use a dynamic array. CMenu* menus = new CMenu[10]; // ... delete [] menus; Of course, now I've lost all the benefits of using an STL container. Do I have any other options?

    Read the article

  • Strange calculation problem in C multiply by 1.2 fails

    - by DoomStone
    I have this c code, where i need to calculate a dobule from a long. double result; long t2_value; t2_value = 72; result = t2_value * 1.2; Now this code crashes at "result = t2_value * 1.2;" only with the error "Vector 0000000006". Here is the strange thing, if i replace result = t2_value * 1.2; with result = 72 * 1.2; evything works just as it should, i have tryed type casting t2_value as an double result = ((double)t2_value * 1.2); or making it an int istead of a long, but nothing helps.

    Read the article

  • algorithms that destruct and copy_construct

    - by FredOverflow
    I am currently building my own toy vector for fun, and I was wondering if there is something like the following in the current or next standard or in Boost? template<class T> void destruct(T* begin, T* end) { while (begin != end) { begin -> ~T(); ++begin; } } template<class T> T* copy_construct(T* begin, T* end, T* dst) { while (begin != end) { new(dst) T(*begin); ++begin; ++dst; } return dst; }

    Read the article

  • C++: need indexed set

    - by user231536
    I need an indexed associative container that operates as follows: initially empty, size=0. when I add a new element to it, it places it at index [size], very similar to a vector's push_back. It increments the size and returns the index of the newly added element. if the element already exists, it returns the index where it occurs. Set seems the ideal data structure for this but I don't see any thing like getting an index from a find operation. Find on a set returns an iterator to the element. Will taking the difference with set.begin() be the correct thing to do in this situation?

    Read the article

< Previous Page | 80 81 82 83 84 85 86 87 88 89 90 91  | Next Page >