Segmentation fault - calculation of inner and outer product of 2 vectros



```
#include <stdio.h>
#DEFINE suntetagmenes 3

double eswterikoginomeno(double dianusmata[][suntetagmenes])
{
    int j;
    double eswteriko=0;
    for (j=0;j<suntetagmenes;j++)
    {
        eswteriko+=dianusmata[0][j]*dianusmata[1][j];
    }
    return(eswteriko);
}

double e3wterikoginomeno(double dianusmata[][suntetagmenes], int i)
{
    double e3wteriko;
    if (i==0)
    {
        e3wteriko=dianusmata[0][1]*dianusmata[1][2]-dianusmata[0][2]*dianusmata[1][1];
    }
    else if (i==1)
    {
        e3wteriko=dianusmata[0][2]*dianusmata[1][0]-dianusmata[0][0]*dianusmata[1][2];
    }
    else
    {
        e3wteriko=dianusmata[0][0]*dianusmata[1][1]-dianusmata[0][1]*dianusmata[1][0];
    }
    return(e3wteriko);
}

int main()
{
    char x='m';
    int count=0, i, j, pra3i, k=0;
    double dianusmata[2][suntetagmenes]={0}, esw_gin, e3w_gin[suntetagmenes]={0};
    while (x=='m')
    {
        for (i=0;i<=1;i++)
        {
            printf("Dwste 3 suntetagmenes gia to dianusma: ");
            for (j=0;j<suntetagmenes;j++)
            {
                scanf("%lf",dianusmata[i][j]);
            }
        }
        printf("Epile3te:\n1.Ypologismos eswterikou ginomenou\n2.Ypologismos e3wterikou ginomenou\n");
        scanf("%d",&pra3i);
        while ((pra3i!=1)&&(pra3i!=2))
        {
            if (count==1)
            {
                exit(-1);
            }
            printf("Dwsate la8os eisodo!\nEpile3te:\n1.Ypologismos eswterikou ginomenou\n2.Ypologismos e3wterikou ginomenou\n");
            scanf("%d",&pra3i);
            count=1;
        }
        esw_gin=eswterikoginomeno(dianusmata);
        printf("To eswteriko ginomeno twn dianusmatwn pou dwsate einai %lf.",esw_gin);
        if (esw_gin==0)
        {
            printf("Diladi ta dianusmata einai ka8eta meta3u tous.");
        }
        for (i=0;i<suntetagmenes;i++)
        {
            e3w_gin[i]=e3wterikoginomeno(dianusmata,i);
        }
        printf("To e3wteriko ginomeno twn dianusmatwn pou dwsate einai %lf.",e3w_gin[suntetagmenes]);
        for (i=0;i<suntetagmenes;i++)
        {
            if (e3w_gin[i]==0)
            {
                k++;
            }
        }
        if (k==3)
        {
            printf("Diladi ta dianusmata pou dwsate einai parallila meta3u tous.");
        }
        printf("Pliktrologiste m gia na epistrepsete sto menu i e gia na kanete exit!");
        scanf("%c",&x);
        while ((x!='m')&&(x!='e'))
        {
            printf("Dwsate la8os eisodo!\nPliktrologiste m gia na epistrepsete sto menu i e gia na kanete exit!");
            scanf("%c",&x);
        }
    }
    return(0);
}
```

SEGMENTATION FAULT :( I DON'T KNOW WHAT TO DO... HELP ME PLEASE!
A segmentation fault in this case probably means you accessed one of the arrays out of bounds. Start up a debugger and keep a watch on your indices.
let, y = (1 – 2 tan x)(5 + 4 sin x)we have to find dy/dxas we can observe that y is a product of two functions say u and v where,u = (1 – 2tan x) and v = (5 + 4sin x)∴ y = uvas we know that to find the derivative of product of two function we apply product rule of differentiation.by product rule, we have –…equation 1as, u = (1 – 2tan x)∴ ⇒ ⇒ …..equation 2 {∵ }as, v = 5 + 4sin x⇒ ⇒ …equation 3 {∵ }∴ from equation 1, we can find dy/dx∴ using equation 2 & 3, we get –⇒ ⇒ ∵ sin x = tan x cos x , so we get –⇒ hence, check out the intersect function.
here is one approach:
% generate a rectangular boundry
rectx = [0.1 0.1 0.9 0.9];
recty = [0.1 0.5 0.5 0.1];
rect = polyshape(rectx,recty);

% initialize a figure for display purposes
figure(1);clf
titles = [...
 "all lines";...
 "partially within";...
 "exclusively within"];
for i = 1:3
 subplot(1,3,i)
 hold on
 title(titles(i))
 plot(rect)
 xlim([0 1])
 ylim([0 1])
end

% define the number of line segments to generate
nlines = 25;

% initialize a structure to store the lines (if you need the data later)
lines = struct();

% generate each line, calculate it's intersection conditions, and plot
for i=1:nlines
 
 % generate points for a random line segment
 lines(i).points = rand(2);
 
 % section the line into parts at intersection with the rectangle
 [in, out] = intersect(rect, lines(i).points);
 
 % plot all the lines that were generated
 subplot(1,3,1)
 line(lines(i).points(:,1),lines(i).points(:,2))
 
 % plot lines that are partially within the boundary
 if isempty(in)==0
 subplot(1,3,2)
 line(lines(i).points(:,1),lines(i).points(:,2))
 end
 
 % plot lines that are exclusively within the boundary
 if isempty(out)==1
 subplot(1,3,3)
 line(lines(i).points(:,1),lines(i).points(:,2))
 end
end
here is the output: doing integration yields-then finally f(x)=-x cos x + sin xto calculate derivative of the above function f(x) we have to apply formula of derivation of products of two functions-f(x) =-x cos(x)+sin(x)f’(x) =-[x(-sin x)+cos x.1]+cos x ;{by formula d/dx (f.g)=f.g’+g.f’}f’(x) =-(-x sin x) - cos x + cos xf’(x) = x.sin(x) ?answer :




step 1 of 6:


given, in a sample of 20 weld failures, 85% of them occur in the weld metal itself, and the remaining 15% occur in the base metal.


let x follows binomial distribution with probability mass function is




p(x: n,p) = (1 - p , x = 0, 1, 2, ….., n.


where,
n = sample size
 = 20
x = random variable
p = probability of success
 = 15% 
 = 0.15
q = 1 - p (probability of failure)


mean of the binomial distribution is 


 = np


variance of the binomial distribution is 


 = npq


\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_




step 2 of 6:




1. the claim is to find the probability that exactly five of them are base metal failures


we have to find p(x=5) 


p(x: n,p) = (1 - p , x = 0, 1, 2, ….., n.


 where, n = 20, p = 0.15 and x = 5


p(x = 5) = (1 - 0.15


 = (15504) (0.0000759) (0.087354)


 = 0.1028


hence, the probability that exactly five of them are base metal failures is 0.1028.


\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_




step 3 of 6:




1. the claim is to find the probability that fewer than four of them are base metal failures


we have to find p(x < 4) = p(x = 0) + p( x = 1) + p(x = 2) + p(x = 3) 






p(x: n,p) = (1 - p , x = 0, 1, 2, ….., n.


 where, n = 20, p = 0.15 and x = 0, 1, 2 and 3


p(x < 4) = (1 - 0.15+ (1 - 0.15+


 (1 - 0.15+ (1 - 0.15


 = (1) (1) (0.03876) + (20) (0.15) (0.0456) +
 (190) (0.0225) (0.053646) + (1140) ( 0.003375) (0.0631134)


 = 0.03876 + 0.1368 + 0.2293 + 0.2428


 = 0.6477


hence, the probability that fewer than four of them are base metal failures 0.6477


\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_




step 4 of 6:




c) the claim is to find the probability that none of them are base metal failures.


we have to find p(x=0) 


p(x: n,p) = (1 - p , x = 0, 1, 2, ….., n.


 where, n = 20, p = 0.15 and x = 0


p(x = 0) = (1 - 0.15


 = (1) (1) (0.03876) 


 = 0.03876


hence, the probability that none of them are base metal failures is 0.03876


\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_




step 5 of 6:




d) the claim is to find the mean number of base metal failures..


 mean of the binomial distribution is = np


where, n = 20, and p = 0.15


substitute these values in 


then, = (20) (0.15)


 = 3


hence, the mean number of of base metal failures is 3.


\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_




step 6 of 6:




e) the claim is to find the standard deviation of the number of base metal failures..


standard deviation of the binomial distribution is 


where, n = 20, p = 0.15 and q = 1 - p


 = 1 - 0.15


 = 0.85


substitute these values in 


then, 


 


 = 1.596


hence, the standard deviation of the number of base metal failures is 1.596.


\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ A couple of notes to get started:



> 
> .apply(literal\_eval)
> 
> 
> 


Wouldn't this be better as `map`?



> 
> I then re-create the Dask DF:
> 
> 
> ddf = dd.from\_pandas(ddf\_out, npartitions=nCores)
> 
> 
> 


`ddf_out` was already a dask dataframe, I don't know why you had to do this.



> 
> The columns in result seem to match those in metadir.
> 
> 
> 


The value of `result.columns` is taken from the meta you provided, no computing happens until you ask for it (dask is lazy in most operations). Does the ValueError exception not provide further information?


Here is a full example



```
x = ({'F9_07_PZ_COMP_DIRECT': '0',
  'F9_07_PZ_DIRTRSTKEY_NAME': 'DEBRA MEALY',
  'F9_07_PZ_COMP_OTHER': '0',
  'F9_07_PZ_COMP_RELATED': '0',
  'F9_07_PZ_TITLE': 'CHAIR PERSON',
  'F9_07_PZ_AVE_HOURS_WEEK': '1.00',
  'F9_07_PC_TRUSTEE_INDIVIDUAL': 'X'},
 {'F9_07_PZ_COMP_DIRECT': '0',
  'F9_07_PZ_DIRTRSTKEY_NAME': 'HELEN GORDON',
  'F9_07_PZ_COMP_OTHER': '0',
  'F9_07_PZ_COMP_RELATED': '0',
  'F9_07_PZ_TITLE': 'VICE CHAIR',
  'F9_07_PZ_AVE_HOURS_WEEK': '1.00',
  'F9_07_PC_TRUSTEE_INDIVIDUAL': 'X'})
df = pd.DataFrame({'a': x})
d = dd.from_pandas(df, 1)
meta = pd.DataFrame(columns=['F9_07_PZ_COMP_DIRECT', 
       'F9_07_PZ_DIRTRSTKEY_NAME',
       'F9_07_PZ_COMP_OTHER', 'F9_07_PZ_COMP_RELATED', 'F9_07_PZ_TITLE',
       'F9_07_PZ_AVE_HOURS_WEEK', 'F9_07_PC_TRUSTEE_INDIVIDUAL'], dtype="O")
d.map_partitions(lambda df: df.a.apply(pd.Series), meta=meta).compute()

```

How did I know what `meta` to use? I applied the function to the pandas dataframe - you might use a small piece of the dataframe to do this.


Some additional notes:


* it is an anti-pattern to load the data with pandas, pass to dask workers and then gather the whole result back to a pandas (in memory) dataframe, you are very unlikely to see a speedup this way and may incur a lot of overhead. You are better off loading with something like `dd.read_csv`, and aggregating or writing with dask functions too. Only `compute()` on something that will be small or not return anything (because it involves writing the output). The official examples do not use from\_pandas.
* string and dict processing are python methods, and so hold the interpreter lock (GIL) of any python function: threads will not actually run in parallel. To get parallelism, you need to run in processes, which is most easily achieved using <https://docs.dask.org/en/latest/setup/single-distributed.html>
* the distributed scheduler also gives you access to the dashboard, which has a lot of useful information to diagnose how your system is running. You can also configure a lot about its behaviour, in case you have firewall rules you need to obey. [image] endermaz41:

didn't know what to put in the error portion

first of all, err(…) is a value, not a type. since err is a variant ("constructor" if you like) of enum result, if you invoke it, you get a value of type result. you won't get a value of the error type itself, much less a type.

… 4th attempt! Now handles GroupItems. Feel free to ignore attempt 3, I've left it just for learning purposes. There are two ways you may want to handle groups: 1) calculate area for each individual item inside the group, or 2) calculate the aggregate area of all the grouped items. If you want option 2) just comment out the itemsInsideGroupItems line.

 

Just for fun I also changed the way the parameters work for specifying the target area value and unit. I put them in a string. Example values are: '4 square inches', '4in','4 sq inch' will give same result. Other examples are:'100mm', '800 pt'. If the parameter is a number, not a string, it will be interpreted as points.

 

 


```
// start with the selected items
var items = app.activeDocument.selection;

// comment out the following line if you want each groups' area to be calculated, rather than the items inside each group individually
items = itemsInsideGroupItems(items);

// this is where you specify your target size ()
scaleItemsToArea(items, '4 square inches');

function scaleItemsToArea(items, targetString) {
    // very simple parsing of targetString
    targetString = String (targetString);
    var targetAreaInSquareUnits = Number(targetString.match(/\d+/)[0]);
    var unitType;
    // note: only looks for 'in' or 'mm'
    if (targetString.search(/(in|\")/) > -1) {
        unitType = 'in';
    } else if (targetString.search(/mm/) > -1) {
        unitType = 'mm';
    } else {
        unitType = 'pt'
    }
    // scale each item
    for (var i = 0; i < items.length; i++) {
        scaleToArea(items[i], targetAreaInSquareUnits, unitType);
    }
}
function scaleToArea(item, targetAreaInSquareUnits, unitType) {
    var itemAreaInSquareUnits = areaOfItem(item, unitType);
    var scaleFactor = (Math.sqrt(targetAreaInSquareUnits / itemAreaInSquareUnits)) * 100;
    if (scaleFactor != NaN) {
        item.resize(scaleFactor, scaleFactor);
    }
}
function areaOfItem(item, unitType) {
    var itemAreaInSquareUnits;
    var itemAreaInSquarePoints = areaOfItemInSquarePoints(item);
    if (unitType == 'in') {
        var ptsIn1inch = 72;
        itemAreaInSquareUnits = itemAreaInSquarePoints / (ptsIn1inch * ptsIn1inch);
    } else if (unitType == 'mm') {
        var ptsIn1mm = 2.834645669;
        itemAreaInSquareUnits = itemAreaInSquarePoints / (ptsIn1mm * ptsIn1mm);
    } else {
        // no unitType specified, use points
        itemAreaInSquareUnits = itemAreaInSquarePoints;
    }
    return itemAreaInSquareUnits;
}
function areaOfItemInSquarePoints(item) {
    var area = 0;
    if (item.typename == 'PathItem') {
        area = item.area;
    } else if (item.typename == 'CompoundPathItem') {
        for (var j = 0; j < item.pathItems.length; j++) {
            area += item.pathItems[j].area;
            // $.writeln('item.pathItems[j].area = ' + item.pathItems[j].area + '     area = ' + area);
        }
    } else if (item.typename == 'GroupItem') {
        for (var j = 0; j < item.pageItems.length; j++) {
            area += areaOfItemInSquarePoints(item.pageItems[j]);
            // $.writeln('item.pathItems[j].area = ' + item.pathItems[j].area + '     area = ' + area);
        }
    } else {
        // for other types of items, resort to width x height
        area = item.width * item.height;
    }
    return Math.abs(Math.round(area * 10000) / 10000);
}
function itemsInsideGroupItems(items) {
    // returns an array containing items, including items found inside GroupItems
    try {
        var found = [];
        for (var i = 0; i < items.length; i++) {
            var item = items[i];
            if (item.typename == 'GroupItem') {
                found = found.concat(itemsInsideGroupItems(item.pageItems));
            } else {
                found.push(item);
            }
        }
        return found;
    } catch (e) {
        return found;
    }
}
```
 

 

As usual, not much testing done, so please let me know if it works as you'd expect. - Mark hi,

i think the problem is the dynamo version you’re using.

now i have the most complex geometry (dynamo vers. 2,3,0) without problems.

if possible, can you send us an example to test?

here’s an example:

[[1]](https://aws1.discourse-cdn.com/business6/uploads/dynamobim/original/3x/a/b/abcdb448d6e4193cee39105fb567675cbb19a9be.png "1")

durmus a=c and b=d
b=d and `anec`
`ab=1 " and "cdne1`
`cd=1" and "ab=ne1`
answer: a
solution: using `a.m.gtg.m,` we have   
 `a+(1)/(b)gt2sqrt((a)/(b))b+(1)/( c )gt2sqrt((b)/( c )),c+(1)/(d)gt2sqrt(( c )/(d))" and "d+(1)/(a)gt2sqrt((d)/(a))`   
 `implies(a+(1)/(b))(b+(1)/( c ))(c+(1)/(d))(d+(1)/(a))gt16`   
 but,`(a+(1)/(b))(b+(1)/( c ))(c+(1)/(d))(d+(1)/(a))=4xx1xx4xx1=16`   
 `:." "a=(1)/(b),b=(1)/( c ),c=(1)/(d)" and "d=(1)/(a)`   
 `implies" "a=(1)/(b)=2,b=(1)/( c )=(1)/(2),c=(1)/(d)=2" and "d=(1)/(a)=(1)/(2)`   
 `implies" "a=2,b=(1)/(2),c=2" and "d=(1)/(2)`   
 `implies" "a=c" and "b=d` in this we are asked to divide it in 2:3 ratioso, 3+2 = 55, number congruent of line segment is formed.i. firstly, we have to draw a line segment ab of length 7 cm. draw a line with an acute angle from point aii. point the compass on a, and cut the new line with some radiusplace the compass along the line and make 5 arcs. since we need 5 congruent parts, and name the last one as “g”iii. take length of bg as radius draw an arc from a just below it.again, take the length of ag as radius and draw an arc which cuts the previous arc from b, name the intersection point as hconnect b and hiv. taking the same length that we used in line ag, draw arcs along bh and name the points.v. connect the points along ag and bh. name the intercepts on the line ab as m, n, o & p.vi. thus we can divide a line segment as ao:ob = 6:4= 3:2