Search Results

Search found 2093 results on 84 pages for 'sparse matrix'.

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

  • Sparse quadratic program solver

    - by Jacob
    This great SO answer points to a good sparse solver, but I've got constraints on x (for Ax = b) such that each element in x is >=0 an <=N. The first thing which comes to mind is an QP solver for large sparse matrices. Also, A is huge (around 2e6x2e6) but very sparse with <=4 elements per row. Any ideas/recommendations?

    Read the article

  • C Programming matrix

    - by Bilal Khan
    In this program the user enters the # of columns of the matrix and then the entries of the matrix. So, for example, if the user enters 2 for column # and 1 2 3 4 for entries then the program develops a 2 by 2 matrix with 1 2 3 4 as entries. My program works perfectly in such a case. However, if the user for example had only entered 1 2 3 then my program makes a matrix with garbage values. I would like the program in such a case to exit the program. It is a simple question, but it has me baffled. #include<stdio.h> #include<stdlib.h> int main() { int m,x, n, c = 0, d,k, matrix[10][10], transpose[10][10], product[10][10]; printf("Enter the number of columns of matrix "); scanf("%d",&m); if(m<=0){ printf("You entered a invalid value."); exit(0); } else{ printf("Enter the elements of matrix \n"); for( c = 0 ; c < 10 ; c++ ) { for( d = 0 ; d < m ; d++ ) { scanf("%d",&matrix[c][d]); if (matrix[c][d] == 99) // 'x' is character variable I declared to use as a break break; // c = c+1; } if (matrix[c][d] == 99) break; } } printf("\nHere is your matrix:\n"); int i; for(i=0;i<c;i++) { for(d=0;d<m;d++) { printf("%3d ",matrix[i][d]); } printf("\n"); }

    Read the article

  • Flip rotation matrix

    - by azer89
    right now i'm doing character control with kinect. Basically i need to mirror the joint orientation because the character faces the player. Somehow by googling through internet i've done it and everything works very well. But i have little idea about how the math works, here's my code: //------------------------------------------------------------------------------------- Ogre::Quaternion JointOrientationCalculator::buildQuaternion(Ogre::Vector3 xAxis, Ogre::Vector3 yAxis, Ogre::Vector3 zAxis) { Ogre::Matrix3 mat; if(isMirror) { mat = Ogre::Matrix3(xAxis.x, yAxis.x, zAxis.x, xAxis.y, yAxis.y, zAxis.y, xAxis.z, yAxis.z, zAxis.z); Ogre::Matrix3 flipMat(1, 0, 0, 0, 1, 0, 0, 0, -1); mat = flipMat * mat * flipMat; } else { mat = Ogre::Matrix3(xAxis.x, -yAxis.x, zAxis.x, -xAxis.y, yAxis.y, -zAxis.y, xAxis.z, -yAxis.z, zAxis.z); } Ogre::Quaternion q; q.FromRotationMatrix(mat); return q; } when i need to mirror/flip it by axes z i calculate mat = flipMat * mat * flipMat; but i don't understand how this equation works.

    Read the article

  • the easiest way to convert matrix to one row vector

    - by niko
    Hi, Does anyone know what is the best way to create one row matrix (vector) from M x N matrix by putting all rows, from 1 to M, of the original matrix into first row of new matrix the following way: A = [row1; row2, ..., rowM] B = [row1, row2, ..., rowM] Example: A = [1 1 0 0; 0 1 0 1] B = [1 1 0 0 0 1 0 1] I would be very thankful if anyone suggested any simple method or perhaps points out a function if it already exists that could generate matrix B from original matrix A.

    Read the article

  • Can I choose a sparse file as vdev for a zfs pool?

    - by Karl Richter
    man zpool states that a vdev for a zfs pool can be a "regular file". Can I specify a sparse file (the warning about the integrity of the file being determined by the underlying filesystem should apply with the same relevance for a sparse file)? The ZFS administration guide on https://pthree.org/2012/12/04/zfs-administration-part-i-vdevs/ states that file vdevs "must be preallocated, and not sparse files or thin provisioned" (thanks to @jlliagre). On https://wiki.archlinux.org/index.php/Experimenting_with_ZFS sparse files are used without any comment.

    Read the article

  • Representing Sparse Data in PostgreSQL

    - by Chris S
    What's the best way to represent a sparse data matrix in PostgreSQL? The two obvious methods I see are: Store data in a single a table with a separate column for every conceivable feature (potentially millions), but with a default value of NULL for unused features. This is conceptually very simple, but I know that with most RDMS implementations, that this is typically very inefficient, since the NULL values ususually takes up some space. However, I read an article (can't find its link unfortunately) that claimed PG doesn't take up data for NULL values, making it better suited for storing sparse data. Create separate "row" and "column" tables, as well as an intermediate table to link them and store the value for the column at that row. I believe this is the more traditional RDMS solution, but there's more complexity and overhead associated with it. I also found PostgreDynamic, which claims to better support sparse data, but I don't want to switch my entire database server to a PG fork just for this feature. Are there any other solutions? Which one should I use?

    Read the article

  • How does a template class inherit another template class?

    - by hkBattousai
    I have a "SquareMatrix" template class which inherits "Matrix" template class, like below: SquareMatrix.h: #ifndef SQUAREMATRIX_H #define SQUAREMATRIX_H #include "Matrix.h" template <class T> class SquareMatrix : public Matrix<T> { public: T GetDeterminant(); }; template <class T> // line 49 T SquareMatrix<T>::GetDeterminant() { T t = 0; // Error: Identifier "T" is undefined // line 52 return t; // Error: Expected a declaration // line 53 } // Error: Expected a declaration // line 54 #endif I commented out all other lines, the files contents are exactly as above. I receive these error messages: LINE 49: IntelliSense: expected a declaration LINE 52: IntelliSense: expected a declaration LINE 53: IntelliSense: expected a declaration LINE 54: error C2039: 'GetDeterminant' : is not a member of 'SquareMatrix' LINE 54: IntelliSense: expected a declaration So, what is the correct way of inheriting a template class? And what is wrong with this code? The "Matrix" class: template <class T> class Matrix { public: Matrix(uint64_t unNumRows = 0, uint64_t unNumCols = 0); void GetDimensions(uint64_t & unNumRows, uint64_t & unNumCols) const; std::pair<uint64_t, uint64_t> GetDimensions() const; void SetDimensions(uint64_t unNumRows, uint64_t unNumCols); void SetDimensions(std::pair<uint64_t, uint64_t> Dimensions); uint64_t GetRowSize(); uint64_t GetColSize(); void SetElement(T dbElement, uint64_t unRow, uint64_t unCol); T & GetElement(uint64_t unRow, uint64_t unCol); //Matrix operator=(const Matrix & rhs); // Compiler generate this automatically Matrix operator+(const Matrix & rhs) const; Matrix operator-(const Matrix & rhs) const; Matrix operator*(const Matrix & rhs) const; Matrix & operator+=(const Matrix & rhs); Matrix & operator-=(const Matrix & rhs); Matrix & operator*=(const Matrix & rhs); T& operator()(uint64_t unRow, uint64_t unCol); const T& operator()(uint64_t unRow, uint64_t unCol) const; static Matrix Transpose (const Matrix & matrix); static Matrix Multiply (const Matrix & LeftMatrix, const Matrix & RightMatrix); static Matrix Add (const Matrix & LeftMatrix, const Matrix & RightMatrix); static Matrix Subtract (const Matrix & LeftMatrix, const Matrix & RightMatrix); static Matrix Negate (const Matrix & matrix); // TO DO: static bool IsNull(const Matrix & matrix); static bool IsSquare(const Matrix & matrix); static bool IsFullRowRank(const Matrix & matrix); static bool IsFullColRank(const Matrix & matrix); // TO DO: static uint64_t GetRowRank(const Matrix & matrix); static uint64_t GetColRank(const Matrix & matrix); protected: std::vector<T> TheMatrix; uint64_t m_unRowSize; uint64_t m_unColSize; bool DoesElementExist(uint64_t unRow, uint64_t unCol); };

    Read the article

  • Blender - creating bones from transform matrices

    - by user975135
    Notice: this is for the Blender 2.5/2.6 API. Back in the old days in the Blender 2.4 API, you could easily create a bone from a transform matrix in your 3d file as EditBones had an attribute named "matrix", which was an armature-space matrix you could access and modify. The new 2.5+ API still has the "matrix" attribute for EditBones, but for some unknown reason it is now read-only. So how to create EditBones from transform matrices? I could only find one thing: a new "transform()" function, which takes a Matrix too. Transform the the bones head, tail, roll and envelope (when the matrix has a scale component). Perfect, but you already need to have some values (loc/rot/scale) for your bone, otherwise transforming with a matrix like this will give you nothing, your bone will be a zero-sized bone which will be deleted by Blender. if you create default bone values first, like this: bone.tail = mathutils.Vector([0,1,0]) Then transform() will work on your bone and it might seem to create correct bones, but setting a tail position actually generates a matrix itself, use transform() and you don't get the matrix from your model file on your EditBone, but the multiplication of your matrix with the bone's existing one. This can be easily proven by comparing the matrices read from the file with EditBone.matrix. Again it might seem correct in Blender, but now export your model and you see your animations are messed up, as the bind pose rotations of the bones are wrong. I've tried to find an alternative way to assign the transformation matrix from my file to my EditBone with no luck.

    Read the article

  • Learning about sparse columns and filtered indexes

    - by Christian
    I’ve been brushing up on sparse columns and filtered indexes recently and two resources stood out for me as indispensable so I’d thought I’d share them. Those of you studying for Microsoft Certified Master: SQL Server will no doubt have found the Readiness Videos published on TechNet and Kimberley Tripp’s (Blog|Twitter) webcast in this series on Sparse columns provides an excellent resource showing different schema designs and specifically where sparse columns fit in. MCM Readiness Video on Sparse columns by Kimberly Tripp http://technet.microsoft.com/en-us/sqlserver/ff977043 The second resource is a session from this years PASS Summit (2010) by Don Vilen (Twitter) called Filtered Indexes, Sparse Columns: Together, Separately (AD203). I thought this session was great and in combination with Kimberly’s webcast provides the perfect background for anyone wanting to learn this topic, especially for those studying for the MCM knowledge exam. If you attended PASS you should have a login to stream Don’s session but if not you can buy the official DVD’s from http://www.sqlpass.org The DVDs are worthy investment considering how much material you get access to!   Regards, Christian Christian Bolton  - MCA, MCM, MVP Technical Director http://coeo.com - SQL Server Consulting & Managed Services twitter: @christianbolton

    Read the article

  • Sparse linear program solver

    - by Jacob
    This great SO answer points to a good sparse solver, but I've got constraints on x (for Ax = b) such that each element in x is >=0 an <=N. The first thing which comes to mind is an LP solver for large sparse matrices. Any ideas/recommendations?

    Read the article

  • Sparse checkouts and svn:externals

    - by JesperE
    I'm trying to do a sparse checkout of a folder containing externals, but none of the externals are being checked out. This issue seems to indicate that this behavior may be by design, or at least that it isn't clear what the behavior should be. From my point of view, the obvious behavior is that externals are treated just as any other directory, and checked out following the same sparse checkout rules. Is there a way to work around this except manually checking out the externals?

    Read the article

  • Java Matrix Transpose strangeness going on

    - by user1459976
    ok so im making my own Matrix class. and i have a transpose method that transposes a matrix. this is the block in the main method Matrix m1 = new Matrix(4,2); m1.fillMatrix(1,2,3,4,5,6,7,8); System.out.println("before " + m1.toString()); m1.transpose(); System.out.println("after " + m1.toString()); this is where it gets messed up, at m1.transpose(); in the transpose() method public Matrix transpose() { if(isMatrix2) { Matrix tempMatrix = new Matrix(row, col); // matrix2 contents are emptied once this line is executed for(int i=0; i < row; i++) { for(int j=0; j < col; j++) tempMatrix.matrix2[i][j] = matrix2[i][j]; } so for some reason, the tempMatrix.matrix2 has the same id as this.matrix2. so when the codes executes Matrix tempMatrix = new Matrix(row,col); then the contents of this.matrix2 is emptied. anyone know what might be going on here?

    Read the article

  • iPhone OpenGL ES: How do I use gravity vector to correctly transform scene for augmented reality

    - by gpdawson
    I'm trying figure out how to get an OpenGL specified object to be displayed correctly according to the device orientation (ie. according to the gravity vector from the accelerometer, and heading from compass). The GLGravity sample project has an example which is almost like this (despite ignoring heading), but it has some glitches. For example, the teapot jumps 180deg as the device viewing angle crosses the horizon, and it also rotates spuriously if you tilt the device from portrait into landscape. This is fine for the context of this app, as it just shows off an object and it doesn't matter that it does these things. But it means that the code just doesn't work when you attempt to emulate real life viewing of an OpenGL object according to the device's orientation. What happens is that it almost works, but the heading rotation you apply from the compass gets "corrupted" by the spurious additional rotations seen in the GLGravity example project. Can anyone provide sample code that shows how to adjust correctly for the device orientation (ie. gravity vector), or to fix the GLGravity example so that it doesn't include spurious heading changes? //Clear matrix to be used to rotate from the current referential to one based on the gravity vector bzero(matrix, sizeof(matrix)); matrix[3][3] = 1.0; //Setup first matrix column as gravity vector matrix[0][0] = accel[0] / length; matrix[0][1] = accel[1] / length; matrix[0][2] = accel[2] / length; //Setup second matrix column as an arbitrary vector in the plane perpendicular to the gravity vector {Gx, Gy, Gz} defined by by the equation "Gx * x + Gy * y + Gz * z = 0" in which we arbitrarily set x=0 and y=1 matrix[1][0] = 0.0; matrix[1][1] = 1.0; matrix[1][2] = -accel[1] / accel[2]; length = sqrtf(matrix[1][0] * matrix[1][0] + matrix[1][1] * matrix[1][1] + matrix[1][2] * matrix[1][2]); matrix[1][0] /= length; matrix[1][1] /= length; matrix[1][2] /= length; //Setup third matrix column as the cross product of the first two matrix[2][0] = matrix[0][1] * matrix[1][2] - matrix[0][2] * matrix[1][1]; matrix[2][1] = matrix[1][0] * matrix[0][2] - matrix[1][2] * matrix[0][0]; matrix[2][2] = matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0]; //Finally load matrix glMultMatrixf((GLfloat*)matrix);

    Read the article

  • How do I use the gravity vector to correctly transform scene for augmented reality?

    - by gpdawson
    I'm trying figure out how to get an OpenGL specified object to be displayed correctly according to the device orientation (ie. according to the gravity vector from the accelerometer, and heading from compass). The GLGravity sample project has an example which is almost like this (despite ignoring heading), but it has some glitches. For example, the teapot jumps 180deg as the device viewing angle crosses the horizon, and it also rotates spuriously if you tilt the device from portrait into landscape. This is fine for the context of this app, as it just shows off an object and it doesn't matter that it does these things. But it means that the code just doesn't work when you attempt to emulate real life viewing of an OpenGL object according to the device's orientation. What happens is that it almost works, but the heading rotation you apply from the compass gets "corrupted" by the spurious additional rotations seen in the GLGravity example project. Can anyone provide sample code that shows how to adjust correctly for the device orientation (ie. gravity vector), or to fix the GLGravity example so that it doesn't include spurious heading changes? //Clear matrix to be used to rotate from the current referential to one based on the gravity vector bzero(matrix, sizeof(matrix)); matrix[3][3] = 1.0; //Setup first matrix column as gravity vector matrix[0][0] = accel[0] / length; matrix[0][1] = accel[1] / length; matrix[0][2] = accel[2] / length; //Setup second matrix column as an arbitrary vector in the plane perpendicular to the gravity vector {Gx, Gy, Gz} defined by by the equation "Gx * x + Gy * y + Gz * z = 0" in which we arbitrarily set x=0 and y=1 matrix[1][0] = 0.0; matrix[1][1] = 1.0; matrix[1][2] = -accel[1] / accel[2]; length = sqrtf(matrix[1][0] * matrix[1][0] + matrix[1][1] * matrix[1][1] + matrix[1][2] * matrix[1][2]); matrix[1][0] /= length; matrix[1][1] /= length; matrix[1][2] /= length; //Setup third matrix column as the cross product of the first two matrix[2][0] = matrix[0][1] * matrix[1][2] - matrix[0][2] * matrix[1][1]; matrix[2][1] = matrix[1][0] * matrix[0][2] - matrix[1][2] * matrix[0][0]; matrix[2][2] = matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0]; //Finally load matrix glMultMatrixf((GLfloat*)matrix);

    Read the article

  • Logical Matrix .... Solution

    - by Sanju
    Suppose you have an NxN matrix and you have to check whether it's a upper diagonal matrix or not. Is there any generic method to solve this problem? I am elaborating my question: Some thing is like this: Suppose you have NXN matrix having the value of N=4 then matrix will look like this: |5 6 9 2| |1 8 4 9| |5 8 1 6| |7 6 3 2| Its a 4X4 square matrix and again if it's upper triangle matrix it will look something like this: |5 6 9 2| |1 8 4 0| |5 8 0 0| |7 0 0 0| I need to generate a generic program in any language to check wether a square matrix is upper trailgle or not.

    Read the article

  • How to extract a Sub-Matrix from a Matrix ?

    - by ZaZu
    Hello, I have a matrix in a txt file and I want to load the matrix based on my input of number of rows and columns For example, I have a 5 by 5 matrix in the file. I want to extract a 3 by 3 matrix, how can I do that ? I created a nested loop using : FILE *sample sample=fopen("randomfile.txt","r"); for(i=0;i<rows;i++){ for(j=0;j<cols;j++){ fscanf(sample,"%f",&matrix[i][j]); } fscanf(sample,"\n",&matrix[i][j]); } fclose(sample); Sadly the code does not work .. If I have this matrix : 5.00 4.00 5.00 6.00 5.00 4.00 3.00 25.00 5.00 3.00 4.00 23.00 5.00 2.00 352.00 6.00 And inputting 3 for rows and 3 for columns, I get : 5.00 4.00 5.00 6.00 5.00 4.00 3.00 25.00 5.00 Which is obviously wrong , its reading line by line rather than skipping the unmentioned column ... What am I doing wrong ? Thanks !

    Read the article

  • best way to get a vector from sparse matrix

    - by niko
    Hi, I have a m x n matrix where each row consists of zeros and same values for each row. an example would be: M = -0.6 1.8 -2.3 0 0 0; 0 0 0 3.4 -3.8 -4.3; -0.6 0 0 3.4 0 0 In this example the first column consists of 0s and -0.6, second 0 and 1.8, third -2.3 and so on. In such case I would like to reduce m to 1 (get a vector from a given matrix) so in this example a vector would be (-0.6 1.8 -2.3 3.4 -3.8 -4.3) Does anyone know what is the best way to get a vector from such matrix? Thank you!

    Read the article

  • getting bone base and tip positions from a transform matrix?

    - by ddos
    I need this for a Blender3d script, but you don't really need to know Blender to answer this. I need to get bone head and tip positions from a transform matrix read from a file. The position of base is the location part of the matrix, length of the bone (distance from base to tip) is the scale, position of the tip is calculated from the scale (distance from bone base) and rotation part of the matrix. So how to calculate these? bone.base([x,y,z]) # x,y,z - floats bone.tip([x,y,z])

    Read the article

  • how can i get rotation vector from matrix4x4 in xna?

    - by mr.Smyle
    i want to get rotation vector from matrix to realize some parent-children system for models. Matrix bonePos = link.Bone.Transform * World; Matrix m = Matrix.CreateTranslation(link.Offset) * Matrix.CreateScale(link.gameObj.Scale.X, link.gameObj.Scale.Y, link.gameObj.Scale.Z) * Matrix.CreateFromYawPitchRoll(MathHelper.ToRadians(link.gameObj.Rotation.Y), MathHelper.ToRadians(link.gameObj.Rotation.X), MathHelper.ToRadians(link.gameObj.Rotation.Z)) //need rotation vector from bone matrix here (now it's global model rotation vector) * Matrix.CreateFromYawPitchRoll(MathHelper.ToRadians(Rotation.Y), MathHelper.ToRadians(Rotation.X), MathHelper.ToRadians(Rotation.Z)) * Matrix.CreateTranslation(bonePos.Translation); link.gameObj.World = m; where : link - struct with children model settings, like position, rotation etc. And link.Bone - Parent Bone

    Read the article

  • Setting ModelView matrix using rotate, translate, etc.. vs setting manual matrix

    - by guymic
    When setting the ModelView matrix you normally go through several transformations from the identity matrix. for example: glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glRotatef(270.0f, 0.0f, 0.0f, 1.0f); glTranslatef(-rect.size.height / 2, -rect.size.width / 2, 0.0f); Instead of doing those operations one after the other (assume there are more than two), wouldn't it be more efficient to simply pre-calculate the resulting matrix and set the ModelView matrix to this manual matrix?

    Read the article

  • Vectorizatoin of index operation for a scipy.sparse matrix

    - by celil
    The following code runs too slowly even though everything seems to be vectorized. from numpy import * from scipy.sparse import * n = 100000; i = xrange(n); j = xrange(n); data = ones(n); A=csr_matrix((data,(i,j))); x = A[i,j] The problem seems to be that the indexing operation is implemented as a python function, and invoking A[i,j] results in the following profiling output 500033 function calls in 8.718 CPU seconds Ordered by: internal time ncalls tottime percall cumtime percall filename:lineno(function) 100000 7.933 0.000 8.156 0.000 csr.py:265(_get_single_element) 1 0.271 0.271 8.705 8.705 csr.py:177(__getitem__) (...) Namely, the python function _get_single_element gets called 100000 times which is really inefficient. Why isn't this implemented in pure C? Does anybody know of a way of getting around this limitation, and speeding up the above code? Should I be using a different sparse matrix type?

    Read the article

  • Sparse checkout in Git 1.7.0?

    - by davr
    With the new sparse checkout feature in Git 1.7.0, is it possible to just get the contents of a subdirectory like how you can in SVN? I found this example, but it preserves the full directory structure. Imagine that I just wanted the contents of the 'perl' directory, without an actual directory named 'perl'. -- EDIT -- Example: My git repository contains the following paths repo/.git/ repo/perl/ repo/perl/script1.pl repo/perl/script2.pl repo/images/ repo/images/image1.jpg repo/images/image2.jpg repo/doc/ repo/doc/readme.txt repo/doc/help.txt What I want is to be able to produce from the above repository this layout: repo/.git/ repo/script1.pl repo/script2.pl However with the current sparse checkout feature, it seems like it is only possible to get repo/.git/ repo/perl/script1.pl repo/perl/script2.pl which is NOT what I want. Thanks.

    Read the article

  • Discrete and Continuous Classifier on Sparse Data

    - by Chris S
    I'm trying to classify an example, which contains discrete and continuous features. Also, the example represents sparse data, so even though the system may have been trained on 100 features, the example may only have 12. What would be the best classifier algorithm to use to accomplish this? I've been looking at Bayes, Maxent, Decision Tree, and KNN, but I'm not sure any fit the bill exactly. The biggest sticking point I've found is that most implementations don't support sparse data sets and both discrete and continuous features. Can anyone recommend an algorithm and implementation (preferably in Python) that fits these criteria? Libraries I've looked at so far include: Orange (Mostly academic. Implementations not terribly efficient or practical.) NLTK (Also academic, although has a good Maxent implementation, but doesn't handle continuous features.) Weka (Still researching this. Seems to support a broad range of algorithms, but has poor documentation, so it's unclear what each implementation supports.)

    Read the article

  • create a sparse BufferedImage in java

    - by elgcom
    I have to create an image with very large resolution, but the image is relatively "sparse", only some areas in the image need to draw. For example with following code /* this take 5GB memory */ final BufferedImage img = new BufferedImage( 36000, 36000, BufferedImage.TYPE_INT_ARGB); /* draw something */ Graphics g = img.getGraphics(); g.drawImage(....); /* output as PNG */ final File out = new File("out.png"); ImageIO.write(img, "png", out); The PNG image on the end I created is ONLY about 200~300 MB. The question is how can I avoid creating a 5GB BufferedImage at the beginning? I do need an image with large dimension, but with very sparse color information. Is there any Stream for BufferedImage so that it will not take so much memory?

    Read the article

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