Questions tagged [triangular]

Use this tag when you have a programmatic problem related to coordinates, area, or any other property of a shape that forms a triangle.

The shape formed by a polygon which has three sides is said to be triangular in nature.

Triangular shape has been discussed, analyzed, formed mathematical formulas around, explained in different contexts since the inception of the idea of geometry.

You can read more about triangular shape and it's properties here.

157 questions
49
votes
7 answers

Linear index upper triangular matrix

If I have the upper triangular portion of a matrix, offset above the diagonal, stored as a linear array, how can the (i,j) indices of a matrix element be extracted from the linear index of the array? For example, the linear array [a0, a1, a2, a3,…
Robert T. McGibbon
  • 5,075
  • 3
  • 37
  • 45
15
votes
2 answers

Algorithm for labeling edges of a triangular mesh

Introduction As part of a larger program (related to rendering of volumetric graphics), I have a small but tricky subproblem where an arbitrary (but finite) triangular 2D mesh needs to be labeled in a specific way. Already a while ago I wrote a…
Reunanen
  • 7,921
  • 2
  • 35
  • 57
13
votes
6 answers

Is there around a straightforward way to invert a triangular (upper or lower) matrix?

I'm trying to implement some basic linear algebra operations and one of these operations is the inversion of a triangular (upper and/or lower) matrix. Is there an easy and stable algorithm to do that? Thank you.
tunnuz
  • 23,338
  • 31
  • 90
  • 128
11
votes
4 answers

How can I create a triangular matrix based on a vector, in MATLAB?

Let's say I've got a vector like this one: A = [101:105] Which is really: [ 101, 102, 103, 104, 105 ] And I'd like to use only vector/matrix functions and operators to produces the matrix: 101 102 103 104 105 102 103 104 105 0 103 104 105 0 …
Shalom Craimer
  • 20,659
  • 8
  • 70
  • 106
8
votes
3 answers

How to efficiently store a triangular matrix in memory?

I want to store a lower triangular matrix in memory, without storing all the zeros. The way I have implemented it is by allocating space for i + 1 elements on the ith row. However, I am new to dynamic memory allocation in C and something seems to be…
6
votes
2 answers

Making grid triangular mesh quickly with Numpy

Consider a regular matrix that represents nodes numbered as shown in the figure: I want to make a list with all the triangles represented in the figure. Which would result in the following 2 dimensional…
Miguel
  • 1,293
  • 1
  • 13
  • 30
6
votes
3 answers

Solve *sparse* upper triangular system

If I want to solve a full upper triangular system, I can call linsolve(A,b,'UT'). However this currently is not supported for sparse matrices. How can I overcome this?
olamundo
  • 23,991
  • 34
  • 108
  • 149
5
votes
3 answers

Generate random locations within a triangular domain

I want to generate x and y having a uniform distribution and limited by [xmin,xmax] and [ymin,ymax] The points (x,y) should be inside a triangle. How can I solve such a problem?
Elena Popa
  • 317
  • 3
  • 8
5
votes
2 answers

How to convert triangular matrix indexes in to row, column coordinates?

I have these indexes: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,etc... Which are indexes of nodes in a matrix (including diagonal elements): 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 etc... and I need to get i,j coordinates from these…
Martin877
  • 263
  • 2
  • 10
5
votes
2 answers

Armadillo c++: Is there a specific way for creating efficiently triangular or symmetric matrix

I am using armadillo mostly for symmetric and triangular matrices. I wanted to be efficient in terms of memory storage. However, it seems there is no other way than to create a new mat and fill with zeros(for triangular) or with duplicates(for…
user2638923
  • 51
  • 1
  • 3
4
votes
1 answer

How to put the scaling on the ticks in ternary plot instead of x and y axis

I am try to work out with my atomic composition with ternary phase diagram, here is my picture I wish to put my scale to the ticks on the ternary phase diagram (i.e. those triangular axis) instead of x and y axis. Is there a ways to put the scale…
4
votes
3 answers

How to efficiently generate lower triangle indices of a symmetric matrix

I need to generate lower triangle matrix indices (row and columns pairs). The current implementation is inefficient (memory wise) specially when symmetric matrix gets big (more than 50K rows). Is there a better way? rows <- 2e+01 id <-…
user3147662
  • 155
  • 6
4
votes
1 answer

fast way to get the indices of a lower triangular matrix as 1 dimensional list in python

Given the number of rows (or columns) , n, of a square matrix, I am trying to get the index pairs of the lower triangular matrix in a 1 dimensional list. So far I thought of the following solution: def getLowerTriangularIndices(n): inds=[]; …
pacodelumberg
  • 2,214
  • 4
  • 25
  • 32
3
votes
3 answers

Convert upper triangular matrix into vector In Fortran

I would like to convert upper triangle part of the matrix to the vector. For example I have the following matrix (4x4 for simplicity): 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 How can I get upper…
Abracadabra
  • 201
  • 1
  • 10
3
votes
1 answer

What is the simplest way to create an upper triangle tensor with Tensorflow?

Similar to this question, I want to convert this tensor tensor = tf.ones((5, 5)) tf.Tensor( [[1. 1. 1. 1. 1.] [1. 1. 1. 1. 1.] [1. 1. 1. 1. 1.] [1. 1. 1. 1. 1.] [1. 1. 1. 1. 1.]], shape=(5, 5), dtype=float32) to an upper triangular tensor with…
user17185996
1
2 3
10 11