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
3
votes
1 answer

R - how do I replace the lower triangular of part of a non-square matrix with the lower triangular of a square matrix?

I have two matrices in R, a square matrix, and a non-square matrix: dataMatrix1, a 5x5 matrix: 1 2 3 4 3 2 1 3 5 7 3 3 1 1 8 4 5 1 1 5 1 7 8 5 1 dataMatrix2, a 5x8 matrix: 1 0.2 0.3 0.4 0.3 0.9 0.6 0.5 0.2 1 0.3 0.5 0.7 0.8 0.6 0.1 0.3 0.3 1 0.1…
Abdel
  • 5,826
  • 12
  • 56
  • 77
3
votes
2 answers

Column Vector to Transposed Triangular Matrix in Matlab?

If I have a vector A = [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14] Is there any way to convert this to a matrix [0 2 5 9 14 1 4 8 13 0 3 7 12 0 0 6 11 0 0 0 10 0 0 0 0 ] For vector A of length 2016. So far: n =…
Tom Haddow
  • 230
  • 1
  • 10
3
votes
1 answer

stm32L4 : How to generate triangular wave using DAC DMA, uneven slopes

I am trying to generate a triangular wave of frequency 8kHz using DAC and DMA. DAC is triggered using a timer so that the DAC speed will be 1 MSPS. I am working on stm32L476 discovery board. I am using stm32CUBEMX for code initialization. My…
user8398475
  • 61
  • 2
  • 7
3
votes
1 answer

Filling a plane with triangles (Triangulation)

I tried to create an image like the one below as a random background for a website, but after multiple attempts I couldn't find an algorithm that gets the job done. What should the program do? It should be able to fill a plane randomly with…
3
votes
1 answer

How to detect all regions that are surrounded by n line segments?

When you draw 3 line segments in a 2-dimensional plane, it might compose a triangle. How can I find all polygons that are produced by n line segments? Are there any efficient algorithms I can use? Input: first and last point coordinate for each line…
Izumi Kawashima
  • 1,197
  • 11
  • 25
3
votes
2 answers

Triangular distribution in Java

I have 4 parts, every part 10000 times, which should fit into case, and the dimensions of the parts are given by uniform, normal and triangular distribution by randomly generating numbers in added dimensions of each distribution. For each 4 parts…
Marek Valda
  • 35
  • 1
  • 5
3
votes
5 answers

What is the way to invert a triangular matrix in R?

I have an upper triangular matrix and I'd like to compute its inverse in a fast way. I tried qr.solve() but I have the feeling that it's equivalent to solve(), and that it does not exploit the triangular nature of the input matrix. What is the best…
Mark Morrisson
  • 2,543
  • 4
  • 19
  • 25
3
votes
1 answer

Solving a sparse upper triangular system in Eigen?

For dense matrices, the following code solves x^T A = b^T just fine. Matrix3d A; RowVector3d bT, xT; A << 1, 2, 3, 0, 5, 6, 0, 0, 9; bT << 1, 2, 3; xT = A.triangularView().solve(bT); printf("(%g, %g, %g)", xT(0),…
user2646234
  • 197
  • 1
  • 8
3
votes
1 answer

Multiple subplots in triangular form using matplotlib

I have 6 lists and I want to create scatterplots for all possible combinations. This means that I want to create n(n-1)/2 combinations, so 15 plots. I have done this correctly based on the following script. for i in d: for j in d: …
fgypas
  • 326
  • 2
  • 11
2
votes
2 answers

Can't get out of While loop(Python 3.9)

I'm a new at programming, I like solving this euler questions and I know there are solutions for this problem but it's not about the problem at all actually. So, i managed to create a working function for finding example: 33. triangular number. It…
2
votes
1 answer

Triangular Distribution Random Variables

First some background on my situation: I need a random triangular distribution and was planning on using Python's random.triangular. The following is the source code (Python 3.6.2): def triangular(self, low=0.0, high=1.0, mode=None): …
Leland Hepworth
  • 876
  • 9
  • 16
2
votes
2 answers

R triangular numbers function

While working on a small program for calculating the right triangular number that fulfils an equation, I stumbled over a page that holds documentation on the function Triangular() Triangular function When I tried to use this, Rstudio says it…
Djaff
  • 173
  • 1
  • 10
2
votes
1 answer

Sawtooth wave Function for integers Javascript

Saby people, I'm trying to write the function which will map this --> ...-5|-4|-3|-2|-1| 0| 1| 2| 3| 4| 5| 6| 7| 8| 9... to this --> ... 3| 0| 1| 2| 3| 0| 1| 2| 3| 0| 1| 2| 3| 0| 1... Ideally if I enter myFunc(-1,4) it will return 3 the second…
Manvel A.
  • 33
  • 5
2
votes
1 answer

Euler 12 need optimization

I have solved euler problem 12, but it needs some optimization. I have read on the euler forums, but it has not helped me optimized it. However, I have managed to get the solution, I just need to speed it up. It currently takes 4 minutes to run.…
05bs001
  • 41
  • 7
2
votes
1 answer

Converting a vector in R into a lower triangular matrix in specific order

I have a vector where the order of the elements are important, say x <- c(1,2,3,4) I would like to arrange my vector into a lower triangular matrix with a specific order where each row contains the preceding element of the vector. My goal is to…
danluuu
  • 23
  • 5
1
2
3
10 11