Search Results

Search found 4708 results on 189 pages for 'dot matrix'.

Page 7/189 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Matlab matrix replacement assignment gives error

    - by Gulcan
    Hello, when i tried to update some part of a matrix, i got the following error message: ??? Assignment has fewer non-singleton rhs dimensions than non-singleton subscripts My code tries to update some values of a matrix that represent a binary image. My code is as follows: outImage(3:5,2:4,1) = max(imBinary(3:5,2:4,1)); When I delete last parameter (1), this time I get the same error. I guess there is a mismatch between dimensions but I could not get it. outImage is a new object that is created at that time (I tried to create it before, but nothing changed). What may be wrong? Thanks in advance, Gulcan

    Read the article

  • MATLAB matrix replacement assignment gives error

    - by Gulcan
    I tried to update some part of a matrix, I got the following error message: ??? Assignment has fewer non-singleton rhs dimensions than non-singleton subscripts My code tries to update some values of a matrix that represent a binary image. My code is as follows: outImage(3:5,2:4,1) = max(imBinary(3:5,2:4,1)); When I delete last parameter (1), this time I get the same error. I guess there is a mismatch between dimensions but I could not get it. outImage is a new object that is created at that time (I tried to create it before, but nothing changed). What may be wrong?

    Read the article

  • Problem sub-total Matrix with rdlc report in vb.NET

    - by Keven
    Hi everyone, I have a matrix and I need to add the money earned this year and past years. However, I must remove the money spent in past years. I must have the separate amount per year and the total of these amounts. This is what gives my matrix: Year = Fields!Year.value =formatnumber((sum(Fields!Results.Value))-(sum(iif( Fields!Year.value & Parameters!choosedYear.Value, Fields!Moneyspent.value,0))), 2) & "$" However, the subtotal gives me an error. What should I do? P.S.: I already found that the subtotal gives me an error because it's not in the scope of the rowgroup1, but is there a way to get the scope in the subtotal? or can anybody find another way to do it?

    Read the article

  • Efficient 4x4 matrix inverse (affine transform)

    - by Budric
    Hi, I was hoping someone can point out an efficient formula for 4x4 affine matrix transform. Currently my code uses cofactor expansion and it allocates a temporary array for each cofactor. It's easy to read, but it's slower than it should be. Note, this isn't homework and I know how to work it out manually using 4x4 co-factor expansion, it's just a pain and not really an interesting problem for me. Also I've googled and came up with a few sites that give you the formula already (http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm). However this one could probably be optimized further by pre-computing some of the products. I'm sure someone came up with the "best" formula for this at one point or another? Thanks.

    Read the article

  • Rotation Matrix calculates by column not by row

    - by pinnacler
    I have a class called forest and a property called fixedPositions that stores 100 points (x,y) and they are stored 250x2 (rows x columns) in MatLab. When I select 'fixedPositions', I can click scatter and it will plot the points. Now, I want to rotate the plotted points and I have a rotation matrix that will allow me to do that. The below code should work: theta = obj.heading * pi/180; apparent = [cos(theta) -sin(theta) ; sin(theta) cos(theta)] * obj.fixedPositions; But it wont. I get this error. ??? Error using == mtimes Inner matrix dimensions must agree. Error in == landmarkslandmarks.get.apparentPositions at 22 apparent = [cos(theta) -sin(theta) ; sin(theta) cos(theta)] * obj.fixedPositions; When I alter forest.fixedPositions to store the variables 2x250 instead of 250x2, the above code will work, but it wont plot. I'm going to be plotting fixedPositions constantly in a simulation, so I'd prefer to leave it as it, and make the rotation work instead. Any ideas? Also, fixed positions, is the position of the xy points as if you were looking straight ahead. i.e. heading = 0. heading is set to 45, meaning I want to rotate points clockwise 45 degrees. Here is my code: classdef landmarks properties fixedPositions %# positions in a fixed coordinate system. [x, y] heading = 45; %# direction in which the robot is facing end properties (Dependent) apparentPositions end methods function obj = landmarks(numberOfTrees) %# randomly generates numberOfTrees amount of x,y coordinates and set %the array or matrix (not sure which) to fixedPositions obj.fixedPositions = 100 * rand([numberOfTrees,2]) .* sign(rand([numberOfTrees,2]) - 0.5); end function obj = set.apparentPositions(obj,~) theta = obj.heading * pi/180; [cos(theta) -sin(theta) ; sin(theta) cos(theta)] * obj.fixedPositions; end function apparent = get.apparentPositions(obj) %# rotate obj.positions using obj.facing to generate the output theta = obj.heading * pi/180; apparent = [cos(theta) -sin(theta) ; sin(theta) cos(theta)] * obj.fixedPositions; end end end P.S. If you change one line to this: obj.fixedPositions = 100 * rand([2,numberOfTrees]) .* sign(rand([2,numberOfTrees]) - 0.5); Everything will work fine... it just wont plot.

    Read the article

  • Typesetting a large matrix in LaTeX

    - by Hooked
    I have a 3x12 matrix I'd like to input into my LaTeX (with amsmath) document but LaTeX seems to choke when the matrix gets larger then 3x10: \begin{equation} \textbf{e} = \begin{bmatrix} 1&1&1&1&0&0&0&0&-1&-1&-1&-1\\ 1&-1&0&0&1&1&-1&-1&0&0&1&-1\\ 0&0&1&-1&1&-1&1&-1&1&-1&0&0 \end{bmatrix} \end{equation} The error: Extra alignment tab has been changed to \cr. tells me that I have more & then the bmatrix environment can handle. Is there a proper way to handle this? Also it seems that the alignment for 1's and the -1's are different, is that also expected of the bmatrix?

    Read the article

  • Matrix xmpp for windows phone with sockets

    - by user1608857
    I am developing a chat application in windows phone. I am using Matrix XMPP library for that. It worked fine using BOSH. Matrix has released a new version for windows phone which supports sockets. I tried connecting to XMPP using the new version. I tried with both BOSH and Sockets. But it is not working. But it didn't worked for me. I have to develop the application with sockets. I included the line xmppClient.Transport=Transport.Bosh; And tried with sockets also xmppClient.Transport=Transport.Sockets;

    Read the article

  • Transposing a matrix

    - by ZaZu
    Hello, I want to transpose a matrix, its a very easy task but its not working with me : int testtranspose(testing *test,testing *test2){ int i,j; (*test2).colsmat2=(*test).rowsmat1; (*test2).rowsmat2=(*test).colsmat1 for(i=0;i<(*test).rowsmat1;i++){ for(j=0;j<(*test).colsmat1;j++){ ((*test2).mat[i][j])=((*test).mat[i][j]); } printf("\n"); } } I thought this is the correct method of doing it, but apparently for a matrix such as : 1 2 3 4 5 6 7 8 I get : 1 2 0 0 3 4 0 0 What is the problem ? Please help, Thanks !

    Read the article

  • ssrs: one static row matrix, multiple columns will not filter out nulls

    - by pbarton99
    Using a ssrs 2005 matrix client side. I want to list the multiple addresses of one person, hence one row, multiple columns. The Column field is =Fields!StreetName.Value. The data details field is =First(Fields!StreetPrefix.Value) & " " & First(Fields!StreetName.Value). The datasource has a row for each address; however, some rows will have nulls since the datasource is composed of outer joins. The column grouping works, but the first column is always empty, (first 2 rows of datasource are null) addresses appear only after the empty column. I want to filter out nulls on the matrix, but its like the filter is ignored. I have also tried having the dataset return an empty string for a null streetname and setting the filter to =Fields!StreetName.Value != ="" but no difference. What am I missing?

    Read the article

  • Values of Variables Matrix NumPy

    - by Max Mines
    I'm working on a program that determines if lines intersect. I'm using matrices to do this. I understand all the math concepts, but I'm new to Python and NumPy. I want to add my slope variables and yint variables to a new matrix. They are all floats. I can't seem to figure out the correct format for entering them. Here's an example: import numpy as np x = 2 y = 5 w = 9 z = 12 I understand that if I were to just be entering the raw numbers, it would look something like this: matr = np.matrix('2 5; 9 12') My goal, though, is to enter the variable names instead of the ints.

    Read the article

  • Building a world matrix

    - by DeadMG
    When building a world projection matrix from scale, rotate, translate matrices, then the translation matrix must be the last in the process, right? Else you'll be scaling or rotating your translations. Do scale and rotate need to go in a specific order? Right now I've got std::for_each(objects.begin(), objects.end(), [&, this](D3D93DObject* ptr) { D3DXMATRIX WVP; D3DXMATRIX translation, rotationX, rotationY, rotationZ, scale; D3DXMatrixTranslation(&translation, ptr->position.x, ptr->position.y, ptr->position.z); D3DXMatrixRotationX(&rotationX, ptr->rotation.x); D3DXMatrixRotationY(&rotationY, ptr->rotation.y); D3DXMatrixRotationZ(&rotationZ, ptr->rotation.z); D3DXMatrixScaling(&translation, ptr->scale.x, ptr->scale.y, ptr->scale.z); WVP = rotationX * rotationY * rotationZ * scale * translation * ViewProjectionMatrix; });

    Read the article

  • MATLAB - Index exceeds matrix dimensions

    - by Jessy
    Hi I have problem with matrix.. I have many .txt files with different number of rows but have the same number of column (1 column) e.g. s1.txt = 1234 rows s2.txt = 1200 rows s2.txt = 1100 rows I wanted to combine the three files. Since its have different rows .. when I write it to a new file I got this error = Index exceeds matrix dimensions. How I can solved this problem? .

    Read the article

  • matrix multiplication with MPI [on hold]

    - by user3695701
    I'm working on an assignment on matrix multiplication with MPI. A*B=C. the requirement is that B should be vertically partitioned. Here's what I intend to do: broadcast matrix A to all processes and scatter B into several slices with each slice containing n/p columns. The following code only works when the number of process(p) is 1. when p1(say 2), I got [cluster2:21080] *** Process received signal *** [cluster2:21080] Signal: Segmentation fault (11) [cluster2:21080] Signal code: Address not mapped (1) [cluster2:21080] Failing at address: (nil) [cluster2:21080] [ 0] /lib/libpthread.so.0(+0xf8f0) [0x7f49f38108f0] [cluster2:21080] [ 1] /lib/libc.so.6(memcpy+0xe1) [0x7f49f35024c1] [cluster2:21080] [ 2] /usr/lib/libmpi.so.0(ompi_convertor_unpack+0x121)[0x7f49f47c88e1] [cluster2:21080] [ 3] /usr/lib/openmpi/lib/openmpi/mca_pml_ob1.so(+0x8a26) [0x7f49f0dcea26] [cluster2:21080] [ 4] /usr/lib/openmpi/lib/openmpi/mca_btl_tcp.so(+0x662c) [0x7f49efce462c] [cluster2:21080] [ 5] /usr/lib/libopen-pal.so.0(+0x1ede8) [0x7f49f42e0de8] [cluster2:21080] [ 6] /usr/lib/libopen-pal.so.0(opal_progress+0x99) [0x7f49f42d5369] [cluster2:21080] [ 7] /usr/lib/openmpi/lib/openmpi/mca_pml_ob1.so(+0x5585) [0x7f49f0dcb585] [cluster2:21080] [ 8] /usr/lib/openmpi/lib/openmpi/mca_coll_tuned.so(+0xcc01) [0x7f49eeeb1c01] [cluster2:21080] [ 9] /usr/lib/openmpi/lib/openmpi/mca_coll_tuned.so(+0x266c) [0x7f49eeea766c] [cluster2:21080] [10] /usr/lib/openmpi/lib/openmpi/mca_coll_sync.so(+0x1388) [0x7f49ef0c0388] [cluster2:21080] [11] /usr/lib/libmpi.so.0(MPI_Bcast+0x10e) [0x7f49f47d025e] [cluster2:21080] [12] ./out(main+0x259) [0x401571] [cluster2:21080] [13] /lib/libc.so.6(__libc_start_main+0xfd) [0x7f49f3498c8d] [cluster2:21080] [14] ./out() [0x400f29] [cluster2:21080] *** End of error message *** Can someone help me? Thanks. //matrices A and B //double* A =(double *)malloc(n*n*sizeof(double)); //double* B =(double *)malloc(n*n*sizeof(double)); //code initializing A,B... //n is the size of the matrix //p is the number of processes //myrank is the rank of calling process MPI_Init (&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &myrank); MPI_Comm_size(MPI_COMM_WORLD, &p); //broadcast A to all processes MPI_Bcast (A, n*n, MPI_DOUBLE, 0, MPI_COMM_WORLD); MPI_Datatype tmp_type, col_type; // extract a slice from B MPI_Type_vector(n, num_of_col_per_slice, n, MPI_DOUBLE, &tmp_type); // position of the first (0) and each next (stride * sizeof(double) ) slice MPI_Type_create_resized(tmp_type, 0, n * sizeof(double), &col_type); MPI_Type_commit(&col_type); //scatter a slice of B to each process MPI_Scatter(B, 1, col_type, B+myrank*n/p, n * n/p, MPI_DOUBLE, 0, MPI_COMM_WORLD); //use blas function to calculate A*sliceOfB and store the resulting slice to C cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, n, n/p, n, 1.0, A, n, B+myrank*n/p, n, 0.0, C+myrank*n/p, n); //gather all those resulting slices into C MPI_Gather (C+myrank*n/p, n*n/p, MPI_DOUBLE, C, n*n/p, MPI_DOUBLE, 0, MPI_COMM_WORLD);

    Read the article

  • Converting a Matrix to a grid of colors

    - by Zach
    I'm currently making a console application in C# (will be going to a Windows Form application in the future. Sooner if needed). My current objective is to have a matrix (current size 52x42) be exported as an image (bitmap, jpeg, png, I'm flexible) where each value in the matrix (0, 1, 2, 3) is portrayed as a white, black, blue, or red square of size 20px x 20px with a grid 1px wide seperating each 'cell'. Can this even be done in a console application, and if so how? If not, what would I need to get it working in a Windows Form application?

    Read the article

  • How to extract a submatrix 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

  • Red Dot Scope Makes Sighting In Long Lenses a Snap

    - by Jason Fitzpatrick
    If you’ve ever used a high power lens, you know how tricky it can be to sight a distant subject as the field of view through the lens is so tiny. This hack takes care of that problem by using a zero-magnification red dot rifle scope. Chris Malcolm enjoys photographing birds and other wildlife with high power lenses. The problem, when shooting with huge 500mm lens and other high power lenses, is that they’re practically telescopes and acquiring a fast moving target like a bird using a through-the-lens technique is very tricky. Malcolm’s solution hinges on mounting a zero-magnification red dot rifle scope in parallel with the lens. His mock up is a bit unpolished (although we can understand not wanting to run out and buy a brand new black scope just for the experiment) but works great to get him on target. Hit up the link below to read more about his build, how be created the rail mount for the scope, and why he opted to mount it to the barrel of the lens and not the hot shoe mount on the camera. 500mm Reflex Lens with Red Dot Sight [via DIY Photography] Make Your Own Windows 8 Start Button with Zero Memory Usage Reader Request: How To Repair Blurry Photos HTG Explains: What Can You Find in an Email Header?

    Read the article

  • importing animations in Blender, weird rotations/locations

    - by user975135
    This is for the Blender 2.6 API. There are two problems: 1. When I import a single animation frame from my animation file to Blender, all bones look fine. But when I import multiple (all of the frames), just the first one looks right, seems like newer frames are affected by older ones, so you get slightly off positions/rotations. This is true when both assigning PoseBone.matrix and PoseBone.matrix_basis. bone_index = 0 # for each frame: for frame_index in range(frame_count): # for each pose bone: add a key for bone_name in bone_names: # "bone_names" - a list of bone names I got earlier pose.bones[bone_name].matrix = animation_matrices[frame_index][bone_index] # "animation_matrices" - a nested list of matrices generated from reading a file # create the 'keys' for the Action from the poses pose.bones[bone_name].keyframe_insert('location', frame = frame_index+1) pose.bones[bone_name].keyframe_insert('rotation_euler', frame = frame_index+1) pose.bones[bone_name].keyframe_insert('scale', frame = frame_index+1) bone_index += 1 bone_index = 0 Again, it seems like previous frames are affecting latter ones, because if I import a single frame from the middle of the animation, it looks fine. 2. I can't assign armature-space animation matrices read from a file to a skeleton with hierarchy (parenting). In Blender 2.4 you could just assign them to PoseBone.poseMatrix and bones would deform perfectly whether the bones had a hierarchy or none at all. In Blender 2.6, there's PoseBone.matrix_basis and PoseBone.matrix. While matrix_basis is relative to parent bone, matrix isn't, the API says it's in object space. So it should have worked, but doesn't. So I guess we need to calculate a local space matrix from our armature-space animation matrices from the files. So I tried multiplying it ( PoseBone.matrix ) with PoseBone.parent.matrix.inverted() in both possible orders with no luck, still weird deformations.

    Read the article

  • Can someone explain the (reasons for the) implications of colum vs row major in multiplication/concatenation?

    - by sebf
    I am trying to learn how to construct view and projection matrices, and keep reaching difficulties in my implementation owing to my confusion about the two standards for matrices. I know how to multiply a matrix, and I can see that transposing before multiplication would completely change the result, hence the need to multiply in a different order. What I don't understand though is whats meant by only 'notational convention' - from the articles here and here the authors appear to assert that it makes no difference to how the matrix is stored, or transferred to the GPU, but on the second page that matrix is clearly not equivalent to how it would be laid out in memory for row-major; and if I look at a populated matrix in my program I see the translation components occupying the 4th, 8th and 12th elements. Given that: "post-multiplying with column-major matrices produces the same result as pre-multiplying with row-major matrices. " Why in the following snippet of code: Matrix4 r = t3 * t2 * t1; Matrix4 r2 = t1.Transpose() * t2.Transpose() * t3.Transpose(); Does r != r2 and why does pos3 != pos for: Vector4 pos = wvpM * new Vector4(0f, 15f, 15f, 1); Vector4 pos3 = wvpM.Transpose() * new Vector4(0f, 15f, 15f, 1); Does the multiplication process change depending on whether the matrices are row or column major, or is it just the order (for an equivalent effect?) One thing that isn't helping this become any clearer, is that when provided to DirectX, my column major WVP matrix is used successfully to transform vertices with the HLSL call: mul(vector,matrix) which should result in the vector being treated as row-major, so how can the column major matrix provided by my math library work?

    Read the article

  • Black Screen: How to set Projection/View Matrix

    - by Lisa
    I have a Windows Phone 8 C#/XAML with DirectX component project. I'm rendering some particles, but each particle is a rectangle versus a square (as I've set the vertices to be positions equally offset from each other). I used an Identity matrix in the view and projection matrix. I decided to add the windows aspect ratio to prevent the rectangles. But now I get a black screen. None of the particles are rendered now. I don't know what's wrong with my matrices. Can anyone see the problem? These are the default matrices in Microsoft's project example. View Matrix: XMVECTOR eye = XMVectorSet(0.0f, 0.7f, 1.5f, 0.0f); XMVECTOR at = XMVectorSet(0.0f, -0.1f, 0.0f, 0.0f); XMVECTOR up = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f); XMStoreFloat4x4(&m_constantBufferData.view, XMMatrixTranspose(XMMatrixLookAtRH(eye, at, up))); Projection Matrix: void CubeRenderer::CreateWindowSizeDependentResources() { Direct3DBase::CreateWindowSizeDependentResources(); float aspectRatio = m_windowBounds.Width / m_windowBounds.Height; float fovAngleY = 70.0f * XM_PI / 180.0f; if (aspectRatio < 1.0f) { fovAngleY /= aspectRatio; } XMStoreFloat4x4(&m_constantBufferData.projection, XMMatrixTranspose(XMMatrixPerspectiveFovRH(fovAngleY, aspectRatio, 0.01f, 100.0f))); } I've tried modifying them to use cocos2dx's WP8 example. XMMATRIX identityMatrix = XMMatrixIdentity(); float fovy = 60.0f; float aspect = m_windowBounds.Width / m_windowBounds.Height; float zNear = 0.1f; float zFar = 100.0f; float xmin, xmax, ymin, ymax; ymax = zNear * tanf(fovy * XM_PI / 360); ymin = -ymax; xmin = ymin * aspect; xmax = ymax * aspect; XMMATRIX tmpMatrix = XMMatrixPerspectiveOffCenterRH(xmin, xmax, ymin, ymax, zNear, zFar); XMMATRIX projectionMatrix = XMMatrixMultiply(tmpMatrix, identityMatrix); // View Matrix float fEyeX = m_windowBounds.Width * 0.5f; float fEyeY = m_windowBounds.Height * 0.5f; float fEyeZ = m_windowBounds.Height / 1.1566f; float fLookAtX = m_windowBounds.Width * 0.5f; float fLookAtY = m_windowBounds.Height * 0.5f; float fLookAtZ = 0.0f; float fUpX = 0.0f; float fUpY = 1.0f; float fUpZ = 0.0f; XMMATRIX tmpMatrix2 = XMMatrixLookAtRH(XMVectorSet(fEyeX,fEyeY,fEyeZ,0.f), XMVectorSet(fLookAtX,fLookAtY,fLookAtZ,0.f), XMVectorSet(fUpX,fUpY,fUpZ,0.f)); XMMATRIX viewMatrix = XMMatrixMultiply(tmpMatrix2, identityMatrix); XMStoreFloat4x4(&m_constantBufferData.view, viewMatrix); Vertex Shader cbuffer ModelViewProjectionConstantBuffer : register(b0) { //matrix model; matrix view; matrix projection; }; struct VertexInputType { float4 position : POSITION; float2 tex : TEXCOORD0; float4 color : COLOR; }; struct PixelInputType { float4 position : SV_POSITION; float2 tex : TEXCOORD0; float4 color : COLOR; }; PixelInputType main(VertexInputType input) { PixelInputType output; // Change the position vector to be 4 units for proper matrix calculations. input.position.w = 1.0f; //===================================== // TODO: ADDED for testing input.position.z = 0.0f; //===================================== // Calculate the position of the vertex against the world, view, and projection matrices. //output.position = mul(input.position, model); output.position = mul(input.position, view); output.position = mul(output.position, projection); // Store the texture coordinates for the pixel shader. output.tex = input.tex; // Store the particle color for the pixel shader. output.color = input.color; return output; } Before I render the shader, I set the view/projection matrices into the constant buffer void ParticleRenderer::SetShaderParameters() { ViewProjectionConstantBuffer* dataPtr; D3D11_MAPPED_SUBRESOURCE mappedResource; DX::ThrowIfFailed(m_d3dContext->Map(m_constantBuffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource)); dataPtr = (ViewProjectionConstantBuffer*)mappedResource.pData; dataPtr->view = m_constantBufferData.view; dataPtr->projection = m_constantBufferData.projection; m_d3dContext->Unmap(m_constantBuffer.Get(), 0); // Now set the constant buffer in the vertex shader with the updated values. m_d3dContext->VSSetConstantBuffers(0, 1, m_constantBuffer.GetAddressOf() ); // Set shader texture resource in the pixel shader. m_d3dContext->PSSetShaderResources(0, 1, &m_textureView); } Nothing, black screen... I tried so many different look at, eye, and up vectors. I tried transposing the matrices. I've set the particle center position to always be (0, 0, 0), I tried different positions too, just to make sure they're not being rendered offscreen.

    Read the article

  • VFP Unit Matrix Multiply problem on the iPhone

    - by Ian Copland
    Hi. I'm trying to write a Matrix3x3 multiply using the Vector Floating Point on the iPhone, however i'm encountering some problems. This is my first attempt at writing any ARM assembly, so it could be a faily simple solution that i'm not seeing. I've currently got a small application running using a maths library that i've written. I'm investigating into the benifits using the Vector Floating Point Unit would provide so i've taken my matrix multiply and converted it to asm. Previously the application would run without a problem, however now my objects will all randomly disappear. This seems to be caused by the results from my matrix multiply becoming NAN at some point. Heres the code IMatrix3x3 operator*(IMatrix3x3 & _A, IMatrix3x3 & _B) { IMatrix3x3 C; //C++ code for the simulator #if TARGET_IPHONE_SIMULATOR == true C.A0 = _A.A0 * _B.A0 + _A.A1 * _B.B0 + _A.A2 * _B.C0; C.A1 = _A.A0 * _B.A1 + _A.A1 * _B.B1 + _A.A2 * _B.C1; C.A2 = _A.A0 * _B.A2 + _A.A1 * _B.B2 + _A.A2 * _B.C2; C.B0 = _A.B0 * _B.A0 + _A.B1 * _B.B0 + _A.B2 * _B.C0; C.B1 = _A.B0 * _B.A1 + _A.B1 * _B.B1 + _A.B2 * _B.C1; C.B2 = _A.B0 * _B.A2 + _A.B1 * _B.B2 + _A.B2 * _B.C2; C.C0 = _A.C0 * _B.A0 + _A.C1 * _B.B0 + _A.C2 * _B.C0; C.C1 = _A.C0 * _B.A1 + _A.C1 * _B.B1 + _A.C2 * _B.C1; C.C2 = _A.C0 * _B.A2 + _A.C1 * _B.B2 + _A.C2 * _B.C2; //VPU ARM asm for the device #else //create a pointer to the Matrices IMatrix3x3 * pA = &_A; IMatrix3x3 * pB = &_B; IMatrix3x3 * pC = &C; //asm code asm volatile( //turn on a vector depth of 3 "fmrx r0, fpscr \n\t" "bic r0, r0, #0x00370000 \n\t" "orr r0, r0, #0x00020000 \n\t" "fmxr fpscr, r0 \n\t" //load matrix B into the vector bank "fldmias %1, {s8-s16} \n\t" //load the first row of A into the scalar bank "fldmias %0!, {s0-s2} \n\t" //calulate C.A0, C.A1 and C.A2 "fmuls s17, s8, s0 \n\t" "fmacs s17, s11, s1 \n\t" "fmacs s17, s14, s2 \n\t" //save this into the output "fstmias %2!, {s17-s19} \n\t" //load the second row of A into the scalar bank "fldmias %0!, {s0-s2} \n\t" //calulate C.B0, C.B1 and C.B2 "fmuls s17, s8, s0 \n\t" "fmacs s17, s11, s1 \n\t" "fmacs s17, s14, s2 \n\t" //save this into the output "fstmias %2!, {s17-s19} \n\t" //load the third row of A into the scalar bank "fldmias %0!, {s0-s2} \n\t" //calulate C.C0, C.C1 and C.C2 "fmuls s17, s8, s0 \n\t" "fmacs s17, s11, s1 \n\t" "fmacs s17, s14, s2 \n\t" //save this into the output "fstmias %2!, {s17-s19} \n\t" //set the vector depth back to 1 "fmrx r0, fpscr \n\t" "bic r0, r0, #0x00370000 \n\t" "orr r0, r0, #0x00000000 \n\t" "fmxr fpscr, r0 \n\t" //pass the inputs and set the clobber list : "+r"(pA), "+r"(pB), "+r" (pC) : :"cc", "memory","s0", "s1", "s2", "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19" ); #endif return C; } As far as i can see that makes sence. While debugging i've managed to notice that if i were to say _A = C prior to the return and after the ASM, _A will not necessarily be equal to C which has only increased my confusion. I had thought it was possibly due to the pointers I'm giving to the VFPU being incrimented by lines such as "fldmias %0!, {s0-s2} \n\t" however my understanding of asm is not good enough to properly understand the problem, nor to see an alternative approach to that line of code. Anyway, I was hoping someone with a greater understanding than me would be able to see a solution, and any help would be greatly appreciated, thank you :-)

    Read the article

  • How to find same-value rectangular areas of a given size in a matrix most efficiently?

    - by neo
    My problem is very simple but I haven't found an efficient implementation yet. Suppose there is a matrix A like this: 0 0 0 0 0 0 0 4 4 2 2 2 0 0 4 4 2 2 2 0 0 0 0 2 2 2 1 1 0 0 0 0 0 1 1 Now I want to find all starting positions of rectangular areas in this matrix which have a given size. An area is a subset of A where all numbers are the same. Let's say width=2 and height=3. There are 3 areas which have this size: 2 2 2 2 0 0 2 2 2 2 0 0 2 2 2 2 0 0 The result of the function call would be a list of starting positions (x,y starting with 0) of those areas. List((2,1),(3,1),(5,0)) The following is my current implementation. "Areas" are called "surfaces" here. case class Dimension2D(width: Int, height: Int) case class Position2D(x: Int, y: Int) def findFlatSurfaces(matrix: Array[Array[Int]], surfaceSize: Dimension2D): List[Position2D] = { val matrixWidth = matrix.length val matrixHeight = matrix(0).length var resultPositions: List[Position2D] = Nil for (y <- 0 to matrixHeight - surfaceSize.height) { var x = 0 while (x <= matrixWidth - surfaceSize.width) { val topLeft = matrix(x)(y) val topRight = matrix(x + surfaceSize.width - 1)(y) val bottomLeft = matrix(x)(y + surfaceSize.height - 1) val bottomRight = matrix(x + surfaceSize.width - 1)(y + surfaceSize.height - 1) // investigate further if corners are equal if (topLeft == bottomLeft && topLeft == topRight && topLeft == bottomRight) { breakable { for (sx <- x until x + surfaceSize.width; sy <- y until y + surfaceSize.height) { if (matrix(sx)(sy) != topLeft) { x = if (x == sx) sx + 1 else sx break } } // found one! resultPositions ::= Position2D(x, y) x += 1 } } else if (topRight != bottomRight) { // can skip x a bit as there won't be a valid match in current row in this area x += surfaceSize.width } else { x += 1 } } } return resultPositions } I already tried to include some optimizations in it but I am sure that there are far better solutions. Is there a matlab function existing for it which I could port? I'm also wondering whether this problem has its own name as I didn't exactly know what to google for. Thanks for thinking about it! I'm excited to see your proposals or solutions :)

    Read the article

  • glm matrix conversion for DirectX

    - by niktehpui
    For on of the coursework specification I need to work with DirectX, so I tried to implement a DirectX Renderer in my small cross-platform framework (to have it optionally available for Windows). Since I want to stick to my dependencies I want use glm for vector/matrix/quaternions math. The vectors seem to be fully compatible with DirectX, but the glm::mat4 is not working properly in DirectX Effects Framework. I assumed the reason is that DirectX uses row majors layouts and OpenGL column majors (although if I remember right internally in HLSL DX uses column major as well), so I transposed the matrix, but I still get no proper results compared to using XNA-Math. XNA-Version of the code (works): XMMATRIX world = XMMatrixIdentity(); XMMATRIX view = XMMatrixLookAtLH(XMVectorSet(5.0, 5.0, 5.0, 1.0f), XMVectorZero(), XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f)); XMMATRIX proj = XMMatrixPerspectiveFovLH(0.25f*3.14f, 1.25f, 1.0f, 1000.0f); XMMATRIX worldViewProj = world*view*proj; m_fxWorldViewProj->SetMatrix(reinterpret_cast<float*>(&worldViewProj)); This works flawlessly and displays the expected colored cube. GLM-Version (does not work): glm::mat4 world(1.0f); glm::mat4 view = glm::lookAt(glm::vec3(5.0f, 5.0f, 5.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f)); glm::mat4 proj = glm::perspective(0.25f*3.14f, 1.25f, 1.0f, 1000.0f); glm::mat4 worldViewProj = glm::transpose(world*view*proj); m_fxWorldViewProj->SetMatrix(glm::value_ptr(worldViewProj)); Displays nothing, screen stays black. I really would like to stick to glm on all platforms.

    Read the article

  • Custom Calculations in a Matrix - Reporting Services 2005

    - by bfrancis
    I am writing a report to show gas usage (in gallons) used by each department. The request is to view each month and the gallons used by each department. A column is required to display what each departments target goal is, based on the gallons of gas they have used in a past time frame. Each departments target goal is x percent less than the total gallons used for said time frame. I currently have a matrix in Reporting Services with departments making up rows, months making up columns, and gallons filling the details. The matrix is being filled by dataset1. I have the data grouping as is requested for each month by each department. My problem is calculating the target goal. My thought was to create a second dataset (dataset2) that returns the gallons used based on the time frame requested. I grouped this data by department. I was hoping I could use the department field in each dataset to make sure the appropriate numbers were used. I added a new column which shows up next to the gallons field. As I attempted to build the Expression I found out that I could only grab the gallons used from dataset2 if I was summing the gallons field. This gives me the total gallons used by every department combined. I have tried to find resources with similar examples of what I am trying to accomplish but I cannot seem to come across one. I am trying to keep this as detailed as possible without making it too wordy. I would be more than happy to clarify or explain into further detail what I have written above if it is needed. If anyone has links, comments, or suggestions they would be greatly appreciated. A very simple visual or what I am hoping to accomplish is below. The months and departments would expand based on the data returned. months ------------------------------ departments| gallons/month | target goal

    Read the article

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